Skip to content

Commit f9db7f0

Browse files
committed
feat: add orderIndepended opts to plugin
1 parent aaecdac commit f9db7f0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/definitions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ObjectId, MongooseModel } from 'mongoose';
55

66
export type OptionsT = {|
77
diffCollectionName: ?string,
8+
orderIndepended: ?boolean,
89
|};
910

1011
export type DiffModelT = MongooseModel & typeof DiffDoc;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export default function plugin(schema: MongooseSchema<any>, options?: OptionsT)
2727
const rhs = this.toObject();
2828

2929
const Diff: DiffModelT = this.constructor.diffModel();
30-
31-
const diffs: Array<RawChangeT> = (findDiff(lhs, rhs, false, (path, key) =>
30+
const orderIndep = options?.orderIndepended || false;
31+
const diffs: Array<RawChangeT> = (findDiff(lhs, rhs, orderIndep, (path, key) =>
3232
excludeFields(path, key, excludedFields)
3333
): any);
3434

0 commit comments

Comments
 (0)