Dexie Cloud Milestone 3 is out #1464
dfahlander
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
Dexie Cloud Milestone 3 is out. The current service is upgraded and there is a new version of dexie-cloud-addon and the sample app, dexie-cloud-todo-app.
Upgrade Instructions
The new version is based on the early alpha of dexie 4.0 and rxjs has been moved to peer dependency, so you need the following dependencies installed in order to upgrade:
For React users, there are two new helper hooks in dexie-react-hooks that you might find usable:
usePermissions()
anduseObservable()
. The former helps you disable buttons that represents actions that the current user does not permissions to perform. The latter is a replacements of `react-use´'s hook with the same name, but it also supports passing in a function that returns an observable. The new hooks are not yet documented but their usage is clearly examplified in the example app.Also, the schema for the cloud tables are updated, so your db declaration needs a version bump:
Server Upgrade Instructions
For you who have purhased the server, you'll need to migrate the backing database:
npm run migrate
News
db.cloud.invites
.usePermissions()
but svelte-, angular and vue users needs to use this method.New feature: Private IDs
Private IDs solves the situation when unauthorized users create singleton objects before they login - to prohibit multiple instances of those singletons in case the same user switches to another device and create the object before logging in there.
Primary keys are considered private when they are prefixed with a '#' and needs only be unique for the same user. They can be created before the user authenticates and when synced, they will not generate multiple instances for the same user as long as the same ID is used in both cases.
Use case 1: A private default todo-list
Let's say you want your user's data not to be empty by default, so you populate a default todo-list with some example todo-items. If we didn't have private IDs, these objects would sync on login, and when user use a new device, an additional instance of the default todo-list will populate and sync to the cloud so that the user would have 2 default todo-lists. Using a private id for the default todo-list, '#defaultTodoList', this ID needs only to be unique for the same user and never get duplicated.
User case 2: Shopping basket without duplications
Let's say you have a shopping basket. Your product list is available on the public realm so unauthorized users can navigate around your products and put them in their private shopping basket. You let shoppingBasket be a Dexie table with productRef as primary key. Whenever the user put an item in their basket, you add an entry with private key
#${productId}
where productId is the primary key of the public products table.When user authenticates, the shopping basket will sync. If the same user had been putting the same item into their shopping basket on another device, the item won't be duplicated.
New feature: Tied realms
Realms are access control placeholders. Tied realms are realms that have a one-to-one relationship with an entity - so that the entire lifecycle of the entity goes hand-in-hand with it's realm. The problem they solve is to prohibit the inconsistency that could otherwise occur when switching an object from being private to being sharable and vice versa. Private objects have a realmId pointing to the user's userId (representing the user's private data). In order to convert a private object to be sharable, a realm needs to be created and the object's realmId needs to be modified to point on the new realmId. However, inconsistently could occur in case the same user would have an offline device with the list before it was made sharable and another device with up-to-date data where the object points out the new realm. If the user deletes the list on the offline device, that operation would not delete the created realm once it becomes synced. With tied realms, this is solved, because the realmId can always be computed from the obejct id, so a delete operation of the object will always do a delete operation of the tied realmId in case it exists - and thanks to Dexie Cloud's consistent operations, that operation will sync consistently once the offline device gets connected and the server will always delete both the object and its realm in case the tied realm exists.
150 more people from the wait list are in
Today, another 150 people from the wait list are able to run
npx dexie-cloud create
and use the beta in full. An update email will soon go out to all of you that have been let in from the wait list.Now and forward...
In Milestone 4 documentation is being improved: consistent operations will be explained with real world examples that show why consistency is a crucial feature of offline-first applications. The documentation of Dexie Cloud API will also be updated and extended with more examples on how to use the API.
But for now, the source of dexie-cloud-todo-app is the best documentation.
Thanks you for being part of this journey!
David
Beta Was this translation helpful? Give feedback.
All reactions