Skip to content

Writing records

Use the idx.set() method to create or modify a record at runtime. Writing to records requires having an authenticated user. All writes will be performed by that user and applied to their records.

If a record is already set, calling idx.set() again will completely replace the existing record content with new content. Alternatively, it is possible to update only a specific portion of an existing record using idx.merge().

Using default aliases

Pass an alias from default aliases and the data that you wish to write to the record.

await idx.set('basicProfile', content)

API reference

Using your aliases

Pass an alias from your aliases object and the data that you wish to write to the record.

await idx.set('myAlias', content)

API reference

Example

await idx.set('basicProfile', {
  name: 'Alan Turing',
  description: 'I make computers beep good.',
  emoji: '💻',
})
recordID of the record

Updating records

Calling idx.set() on an existing record completely replaces the existing content. If you want to keep the existing content and only change some fields, idx.merge() can be used instead.

await idx.set('basicProfile', { name: 'Alan Turing' })
await idx.merge('basicProfile', { emoji: '💻' })
{
  name: 'Alan Turing',
  emoji: '💻',
}

API reference