Once written, data can be updated. This is basic database functionality and it’s readily available.

Flow of data

Check out Writing data (link), since the same logic is being used to update it.

The underlying Ceramic data is updated, after which it gets picked up by OrbisDB instances subscribed to its Models (link).

The indexing process includes Context (link) checks, validation done by Plugins (link), etc.

Indexed data is then queried from OrbisDB directly, but is linked to the underlying Ceramic data via the Stream ID.

UPDATE in OrbisDB

Data updates may happen when explicitly requested by the user or due to Account Relation (link) restrictions. When trying to write new data with single or set Account Relation constraints, the already existing data is updated instead.

Updates require user authentication - check out Authentication (link) part of our SDK Reference.

All update operations are handled by the update SDK method (link).

Code example

Update an entire row

When using replace the entire row is replaced (all columns), but the row id remains the same.

// This will replace the provided row with provided values
const result = await orbis
    .update("ROW_ID")
    .replace(
        {
            column: value,
            column2: value2,
        }
    )
    .run()

Update a row partially

In this case, only columns defined in the set statement will be updated. The method will perform a shallow merge with the existing data.

// { ...oldContent, ...newContent }
const result = await orbis
    .update("ROW_ID")
    .set(
        {
            column: value,
        }
    )
    .run()

Summary

When updating data the same flow applies as it does when writing data (link). Ceramic is used as the source of truth from which OrbisDB Nodes index updated data. Run an update query using orbis.update and you’re ready to go.

The general flow when updating data looks like this: