TinyBase logoTinyBase

getSqlStorage

The getSqlStorage method returns a reference to the SQL storage that the Store is being persisted to.

getSqlStorage(): SqlStorage
returnsSqlStorage

The reference to the SQL storage.

Example

This example creates a Persister object against a newly-created Store (within the createPersister method of a WsServerDurableObject instance) and then gets the SQL storage reference back out again.

import {createMergeableStore} from 'tinybase';
import {createDurableObjectSqlStoragePersister} from 'tinybase/persisters/persister-durable-object-sql-storage';
import {WsServerDurableObject} from 'tinybase/synchronizers/synchronizer-ws-server-durable-object';

export class MyDurableObject extends WsServerDurableObject {
  createPersister() {
    const store = createMergeableStore();
    const persister = createDurableObjectSqlStoragePersister(
      store,
      this.ctx.storage.sql,
    );
    console.log(persister.getSqlStorage() == this.ctx.storage.sql);
    // -> true

    return persister;
  }
}

Since

v6.3.0