DT
Drizzle Team15mo ago
fi

How to plus 1 to the current value of a column when update

How to plus 1 to the current value of a column when updating a record
2 Replies
fi
fi15mo ago
do i need to read the value first then only update it?
Andrii Sherman
Andrii Sherman15mo ago
You can use sql template
db.update(usersTable).set({
field: sql`${usersTable.field} + 1`
})
db.update(usersTable).set({
field: sql`${usersTable.field} + 1`
})