UNPKG

rxdb

Version:

A local-first realtime NoSQL Database for JavaScript applications - https://rxdb.info/

37 lines (36 loc) 1.39 kB
import { RX_STORAGE_NAME_DEXIE } from "./dexie-helper.js"; import { createDexieStorageInstance } from "./rx-storage-instance-dexie.js"; import { ensureRxStorageInstanceParamsAreCorrect } from "../../rx-storage-helper.js"; import { RXDB_VERSION } from "../utils/utils-rxdb-version.js"; import { newRxError } from "../../rx-error.js"; export class RxStorageDexie { name = RX_STORAGE_NAME_DEXIE; rxdbVersion = RXDB_VERSION; constructor(settings) { this.settings = settings; } createStorageInstance(params) { ensureRxStorageInstanceParamsAreCorrect(params); /** * Dexie does not support non-required indexes and must throw if that is used. * @link https://github.com/pubkey/rxdb/pull/6643#issuecomment-2505310082 */ if (params.schema.indexes) { var indexFields = params.schema.indexes.flat(); indexFields.filter(indexField => !indexField.includes('.')).forEach(indexField => { if (!params.schema.required || !params.schema.required.includes(indexField)) { throw newRxError('DXE1', { field: indexField, schema: params.schema }); } }); } return createDexieStorageInstance(this, params, this.settings); } } export function getRxStorageDexie(settings = {}) { var storage = new RxStorageDexie(settings); return storage; } //# sourceMappingURL=rx-storage-dexie.js.map