BlinkDB Logo blinkDB

upsert()

Inserts an entity into the table, or updates it if an entity with the given primary key already exists.

Returns the primary key of the inserted/updated item.

// Insert a new entity
const aliceId = await upsert(userTable, { id: uuid(), name: "Alice", age: 23 });
// Update the entity we just created
await upsert(userTable, { id: aliceId, name: "Alice", age: 16 });
ParameterDescription
tableThe table created by createTable() .
itemThe item to insert/update.

Consider upsertMany() if you want to upsert many items at once.