From e495d8242197283b8f238c78fb67838d56975f44 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 10 Jul 2019 15:25:57 +0200 Subject: [PATCH 1/2] Deprecate `memory.records().get()` --- packages/@orbit/memory/src/memory-cache.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/@orbit/memory/src/memory-cache.ts b/packages/@orbit/memory/src/memory-cache.ts index 9e10e2f20..dd136f833 100644 --- a/packages/@orbit/memory/src/memory-cache.ts +++ b/packages/@orbit/memory/src/memory-cache.ts @@ -1,4 +1,5 @@ /* eslint-disable valid-jsdoc */ +import Orbit from '@orbit/core'; import { clone, Dict } from '@orbit/utils'; import { Record, RecordIdentity, equalRecordIdentities } from '@orbit/data'; import { @@ -8,6 +9,8 @@ import { } from '@orbit/record-cache'; import { ImmutableMap } from '@orbit/immutable'; +const { deprecate } = Orbit; + export interface MemoryCacheSettings extends SyncRecordCacheSettings { base?: MemoryCache; } @@ -34,6 +37,17 @@ export default class MemoryCache extends SyncRecordCache { return this._records[identity.type].get(identity.id); } + records(type: string) { + deprecate( + '`records(type).get(id)` is deprecated, use `getRecordSync(identity)`.' + ); + return { + get: (id: string) => { + return this.getRecordSync({ type, id }); + } + }; + } + getRecordsSync(typeOrIdentities?: string | RecordIdentity[]): Record[] { if (Array.isArray(typeOrIdentities)) { const records: Record[] = []; From bbcd6229c2300c9c057bcf73bd332310c97927df Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Wed, 10 Jul 2019 15:31:32 +0200 Subject: [PATCH 2/2] Deprecate `closeDB()` on indexeddb source --- packages/@orbit/indexeddb/src/source.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@orbit/indexeddb/src/source.ts b/packages/@orbit/indexeddb/src/source.ts index 8221c7591..80028aee5 100644 --- a/packages/@orbit/indexeddb/src/source.ts +++ b/packages/@orbit/indexeddb/src/source.ts @@ -21,7 +21,7 @@ import Orbit, { import { supportsIndexedDB } from './lib/indexeddb'; import IndexedDBCache, { IndexedDBCacheSettings } from './cache'; -const { assert } = Orbit; +const { assert, deprecate } = Orbit; export interface IndexedDBSourceSettings extends SourceSettings { namespace?: string; @@ -86,6 +86,11 @@ export default class IndexedDBSource extends Source await this._cache.reopenDB(); } + closeDB() { + deprecate('`closeDB()` must be called as `cache.closeDB()`.'); + return this.cache.closeDB(); + } + ///////////////////////////////////////////////////////////////////////////// // Resettable interface implementation /////////////////////////////////////////////////////////////////////////////