When updating data in OrbisDB, users are interacting with the underlying decentralized data network, Ceramic. Find out more about the data flow in our Updating data section (link).
Before using the methods, make sure to initialize (link) your OrbisDB SDK and authenticate (link) the user.
OrbisDB updates can perform full or partial row updates.
OrbisDB statements work on the principle of “method chaining” to build and eventually execute the query.
When replacing a row, you need to provide all the required fields (based on the Model (link)).
const result = await orbis
.update("ROW_ID")
.replace(
{
column: value,
column2: value2,
}
)
.run()
Partial row updates will perform a shallow merge of the updated content and the original row. { ...new_content, ...original_row }
const result = await orbis
.update("ROW_ID")
.set(
{
column: value,
}
)
.run()
UPDATE
statements can’t be Context-scoped as the row itself either belongs to a Context or doesn’t.
You do not have to execute the statement immediately. It’s done by either chaining the .run()
or executing it later.
If you decide to postpone the execution, you can access a history of all query runs by accessing the statement.runs
property.
const result = await orbis
.update("ROW_ID")
.replace(
{
column: value,
column2: value2,
}
)
.run()
const statement = orbis
.update("ROW_ID")
.replace(
{
column: value,
column2: value2,
}
)
const result = await statement.run()
console.log(result)
// Log the execution history of this statement
console.log(statement.runs)