How to use the @tanker/datastore-base.transform.identity 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 / datastore / dexie-browser / src / index.js View on Github external
import { errors as dbErrors, transform, type DataStore, type SortParams, type Schema, type BaseConfig } from '@tanker/datastore-base';

export type Config = BaseConfig;
export type { Schema };

class UnsupportedTypeError extends Error {
  name: string;

  constructor(type: string) {
    super(`Dexie can't support search for ${type} values on an index, as they are invalid IndexedDB keys.`);
    this.name = this.constructor.name;
  }
}

const iframe = (typeof window !== 'undefined') && window.parent && window.parent !== window;
const fromDB = iframe ? transform.fixObjects : transform.identity;

Dexie.dataStoreName = 'DexieBrowser';

export default () => class DexieBrowserStore implements DataStore {
  /*:: _db: Dexie; */
  /*:: _indexes: { [table: string]: { [field: string]: bool } }; */

  constructor(db: Dexie) {
    // _ properties won't be enumerable, nor reconfigurable
    Object.defineProperty(this, '_db', { value: db, writable: true });
    Object.defineProperty(this, '_indexes', { value: {}, writable: true });
    return this;
  }

  get className(): string {
    return this.constructor.name;

@tanker/datastore-base

Tanker SDK (datastore base)

Apache-2.0
Latest version published 3 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages