Skip to content

Commit 70f374c

Browse files
committed
Rename loader to migrate.
1 parent cb7c7d7 commit 70f374c

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/loki/spec/generic/migration.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe("load lokijs", () => {
228228
it("test LokiDB with serialization inflation", () => {
229229
let db = new Loki();
230230
db.loadJSONObject(legacyDB as Serialization.Serialized, {
231-
loader: (_1, coll) => {
231+
migrate: (_1, coll) => {
232232
coll.nestedProperties = [{name: "d.msg", path: ["d", "msg"]}];
233233
return false;
234234
}
@@ -258,7 +258,7 @@ describe("load lokijs", () => {
258258

259259
// Transform and dynamic view will not be deserialized.
260260
db.loadJSONObject(legacyDB as Serialization.Serialized, {
261-
loader: (_1, _2, options) => {
261+
migrate: (_1, _2, options) => {
262262
options.nestedProperties = ["d.msg"];
263263
return true;
264264
}

packages/loki/src/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ export namespace Collection {
21862186
export interface DeserializeOptions {
21872187
retainDirtyFlags?: boolean;
21882188
fullTextSearch?: Dict<Analyzer>;
2189-
loader?: (databaseVersion: number, coll: Serialization.Collection, options: Collection.Options<any, any>) => boolean;
2189+
migrate?: (databaseVersion: number, coll: Serialization.Collection, options: Collection.Options<any, any>) => boolean;
21902190

21912191
[collName: string]: any | { proto?: any; inflate?: (src: object, dest?: object) => void };
21922192
}

packages/loki/src/loki.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export class Loki extends LokiEventEmitter {
676676
let coll = null;
677677
const dbColl = dbObj.collections[i];
678678

679-
if (options.loader) {
679+
if (options.migrate) {
680680
// Generate options from serialized collection.
681681
const collOptions: Collection.Options<any, any> = {};
682682

@@ -704,7 +704,7 @@ export class Loki extends LokiEventEmitter {
704704
}
705705
}
706706

707-
if (options.loader(databaseVersion, dbColl, collOptions)) {
707+
if (options.migrate(databaseVersion, dbColl, collOptions)) {
708708
coll = this.addCollection(dbColl.name, collOptions);
709709
for (let j = 0; j < dbColl.data.length; j++) {
710710
delete dbColl.data[j].$loki;
@@ -716,8 +716,7 @@ export class Loki extends LokiEventEmitter {
716716
if (!coll) {
717717
coll = Collection.fromJSONObject(dbObj.collections[i], options);
718718
}
719-
720-
this._collections.push(Collection.fromJSONObject(dbObj.collections[i], options));
719+
this._collections.push(coll);
721720
}
722721
}
723722

0 commit comments

Comments
 (0)