BuildcordDocs

Add or change a row

Change the row that matches, or add it if there's none.

data.upsert does in one step what would otherwise take Find rows, a branch, and Add row or Change rows.

Settings

SettingWhat it does
CollectionWhich collection.
WhereWhich row, such as user = {user.id}. A new row starts with these column = value parts.
SetColumns to replace, one column: value per line.
Add toNumber columns to add to, one column: equation per line, such as xp: 10. A new row starts them from 0.

Ways out

out. Turn on If it fails for a red way out.

Produces

TokenValue
{upserted.id}The number of the row changed or added
{upserted.created}true if it was added, false if it was there already

Notes

  • Runs doing this for the same row take turns, so two messages from a new member at once make one row, not two.
  • Every matching row is changed; make the Where pick one.

Example

A levels bot, on Message sent: add or change the row where user = {user.id}, adding xp: 5.

On this page