Skip to content

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.

Adds a value to a numeric attribute or a set.

// Increment count by 1
db.update(stats).set({ count: add(1) })

Appends values to the end of a list. Maps to DynamoDB’s list_append.

db.update(users).set({ roles: append(["editor"]) })

Sets a value only if the attribute does not already exist.

db.update(users).set({ createdAt: ifNotExists(new Date()) })

Removes an attribute from the item.

db.update(users).set({ temporaryToken: remove() })

Adds unique values to a string, number, or binary set.

db.update(users).set({ tags: addToSet(["featured", "new"]) })

Removes specific values from a set.

db.update(users).set({ tags: deleteFromSet(["old"]) })
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();