Update Actions
Update actions are used within the .set() method of an update operation to modify specific attributes of an item without overwriting the entire record.
Available Actions
Section titled “Available Actions”add(value)
Section titled “add(value)”Adds a value to a numeric attribute or a set.
// Increment count by 1db.update(stats).set({ count: add(1) })append(values)
Section titled “append(values)”Appends values to the end of a list. Maps to DynamoDB’s list_append.
db.update(users).set({ roles: append(["editor"]) })ifNotExists(value)
Section titled “ifNotExists(value)”Sets a value only if the attribute does not already exist.
db.update(users).set({ createdAt: ifNotExists(new Date()) })remove()
Section titled “remove()”Removes an attribute from the item.
db.update(users).set({ temporaryToken: remove() })addToSet(values)
Section titled “addToSet(values)”Adds unique values to a string, number, or binary set.
db.update(users).set({ tags: addToSet(["featured", "new"]) })deleteFromSet(values)
Section titled “deleteFromSet(values)”Removes specific values from a set.
db.update(users).set({ tags: deleteFromSet(["old"]) })Advanced Example
Section titled “Advanced Example”import { add, append, remove } from "@aurios/mizzle";
await db.update(users) .set({ loginCount: add(1), lastLogins: append([new Date()]), resetToken: remove() }) .where(eq(users.id, "123")) .execute();