How to use the @tanker/datastore-base.errors.RecordNotUnique 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 / pouchdb-base / src / index.js View on Github external
bulkAdd = async (table: string, records: Array | Object, ...otherRecords: Array) => {
    const all = (records instanceof Array) ? records : [records, ...otherRecords];
    try {
      const allWithoutRevs = all.map(record => {
        const recordWithoutRev = { ...record };
        delete recordWithoutRev._rev;
        return recordWithoutRev;
      });
      await this._dbs[table].bulkDocs(toDB(allWithoutRevs));
    } catch (e) {
      if (e.status === 409) {
        throw new dbErrors.RecordNotUnique(e);
      }
      throw new dbErrors.UnknownError(e);
    }
  }
github TankerHQ / sdk-js / packages / datastore / dexie-browser / src / index.js View on Github external
put = async (table: string, record: Object) => {
    try {
      await this._db.table(table).put(record);
    } catch (e) {
      if (e.name === 'ConstraintError') {
        throw new dbErrors.RecordNotUnique(e);
      }
      throw new dbErrors.UnknownError(e);
    }
  }

@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