Options
All
  • Public
  • Public/Protected
  • All
Menu

Options for opening a Sync object.

example

The following example is applicable to all Sync objects (i.e., syncClient.document(), syncClient.list(), syncClient.map(), syncClient.stream())

// Attempts to open an existing document with a unique name of 'MyDocument'
// If no such document exists, the promise is rejected
syncClient.document({
  id: 'MyDocument',
  mode: 'open_existing'
})
  .then(...)
  .catch(...);

// Attempts to create a new document with a unique name of 'MyDocument', TTL of 24 hours and initial data `{ name: 'John Smith' }`
// If such a document already exists, the promise is rejected
syncClient.document({
  id: 'MyDocument',
  mode: 'create_new',
  ttl: 86400
  data: { name: 'John Smith' } // the `data` property is only applicable for Documents
})
  .then(...)
  .catch(...);

Hierarchy

Index

Properties

Properties

Optional id

id: string

Sync object SID or unique name.

Optional mode

mode: OpenMode

Mode for opening the Sync object.

Optional ttl

ttl: number

The time-to-live of the Sync object in seconds. This is applied only if the object is created.