Dexie v4.0.5
Features
New CRDT operations: add() and remove() (#1936)
New operations that works consistently across sync: Mathematical addition/subtraction as well as adding or removing string or numbers from array properties.
Add to set
It is now possible to add items to an array property using a sync consistent operation "add":
import { add } from "dexie";
db.friends.update(friend.id, {
hobbies: add([
"skating",
"football"
])
});
Remove from set
import { remove } from "dexie";
db.friends.update(friend.id, {
hobbies: remove([
"curling"
])
});
Mathematical addition and subtraction (number)
import { add, remove } from "dexie";
await db.transaction('rw', db.accounts, () => {
db.accounts.update(accountId1, { balance: remove(100) });
db.accounts.update(accountId2, { balance: add(100) });
});
Mathematical addition and subtraction (bigint)
import { add, remove } from "dexie";
await db.transaction('rw', db.accounts, () => {
db.accounts.update(accountId1, { balance: remove(100n) });
db.accounts.update(accountId2, { balance: add(100n) });
});
Typings
- #1998 TInsertType in table methods on Dexie and Transaction