Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;