How to use the @tanker/datastore-base.mergeSchemas function in @tanker/datastore-base

To help you get started, we’ve selected a few @tanker/datastore-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TankerHQ / sdk-js / packages / core / src / __tests__ / TrustchainStore.spec.js View on Github external
// @flow

import { mergeSchemas } from '@tanker/datastore-base';
import { expect } from '@tanker/test-utils';

import dataStoreConfig, { makePrefix, openDataStore } from './TestDataStore';

import KeyStore from '../Session/LocalUser/KeyStore';
import UserStore from '../Users/UserStore';
import TrustchainStore from '../Trustchain/TrustchainStore';

const schemas = mergeSchemas(
  KeyStore.schemas,
  UserStore.schemas,
  TrustchainStore.schemas,
);

const baseConfig = { ...dataStoreConfig, schemas };

async function makeMemoryDataStore() {
  const config = { ...baseConfig, dbName: `trustchain-${makePrefix()}` };
  const dataStore = await openDataStore(config);
  return { dataStore, config };
}

describe('TrustchainStore', () => {
  const TABLE_METADATA = 'trustchain_metadata';
  const LAST_BLOCK_INDEX_KEY = 'lastBlockIndex';
github TankerHQ / sdk-js / packages / core / src / Session / Storage.js View on Github external
async open(userId: Uint8Array, userSecret: Uint8Array): Promise {
    const { adapter, prefix, dbPath, url } = this._options;

    const schemas = mergeSchemas(
      GlobalSchema,
      KeyStore.schemas,
      ResourceStore.schemas,
      GroupStore.schemas,
    );

    const dbName = `tanker_${prefix ? `${prefix}_` : ''}${utils.toSafeBase64(userId)}`;
    // $FlowIKnow DataStore is a flow interface, which does not support static methods
    this._datastore = await adapter().open({ dbName, dbPath, schemas, url });
    this._schemas = schemas;

    this._keyStore = await KeyStore.open(this._datastore, userSecret);
    this._resourceStore = await ResourceStore.open(this._datastore, userSecret);
    this._groupStore = await GroupStore.open(this._datastore, userSecret);

    await this._checkVersion(userSecret);
github TankerHQ / sdk-js / packages / core / src / __tests__ / TrustchainBuilder.js View on Github external
async init(skipRootBlock?: bool) {
    const schemas = mergeSchemas(
      KeyStore.schemas,
      UserStore.schemas,
      TrustchainStore.schemas,
      GroupStore.schemas,
      UnverifiedStore.schemas,
    );

    this.trustchainKeyPair = tcrypto.makeSignKeyPair();

    this.generator = await Generator.open(this.trustchainKeyPair);

    this.dataStoreConfig = { ...dataStoreConfig, schemas, dbName: `trustchain-${makePrefix()}` };

    const { trustchainId } = this.generator;

    const userIdString = 'let try this for now';
github TankerHQ / sdk-js / packages / core / src / __tests__ / UserStoreBuilder.js View on Github external
export async function makeMemoryDataStore(): Promise> {
  const schemas = mergeSchemas(UserStore.schemas);

  const baseConfig = { ...dataStoreConfig, schemas };
  const config = { ...baseConfig, dbName: `user-store-test-${makePrefix()}` };
  return openDataStore(config);
}
github TankerHQ / sdk-js / packages / core / src / __tests__ / TestDataStore.js View on Github external
export function makeMemoryDataStore(schemas: Array, dbName: string): Promise> {
  const config = { adapter: PouchDBMemory, schemas: mergeSchemas(schemas), dbName: makePrefix() + dbName };
  return openDataStore(config);
}
github TankerHQ / sdk-js / packages / core / src / __tests__ / GroupStoreBuilder.js View on Github external
export async function makeMemoryDataStore(): Promise> {
  const schemas = mergeSchemas(GroupStore.schemas);

  const baseConfig = { ...dataStoreConfig, schemas };
  const config = { ...baseConfig, dbName: `group-store-test-${makePrefix()}` };
  return openDataStore(config);
}

@tanker/datastore-base

Tanker SDK (datastore base)

Apache-2.0
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages