@ewb/mongoose-query-express 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/QueryExpress.js +9 -2
- package/package.json +1 -1
package/lib/QueryExpress.js
CHANGED
|
@@ -24,6 +24,7 @@ export class QueryExpress {
|
|
|
24
24
|
this.addToQuery = this.addToQuery.bind(this);
|
|
25
25
|
this.addToPost = this.addToPost.bind(this);
|
|
26
26
|
this.getDoc = this.getDoc.bind(this);
|
|
27
|
+
this.preHistory = this.preHistory.bind(this);
|
|
27
28
|
}
|
|
28
29
|
async post(req, res, next) {
|
|
29
30
|
try {
|
|
@@ -323,7 +324,13 @@ export class QueryExpress {
|
|
|
323
324
|
req.ewb.queryHistory.setIgnoreFields(this.options.history.ignoreFields);
|
|
324
325
|
}
|
|
325
326
|
req.ewb.queryHistory.setModel(this.handler.model);
|
|
326
|
-
|
|
327
|
+
let doc = this.getDoc(req);
|
|
328
|
+
if (doc) {
|
|
329
|
+
if ('toObject' in doc) {
|
|
330
|
+
doc = doc.toObject();
|
|
331
|
+
}
|
|
332
|
+
req.ewb.queryHistory.setOldDoc(doc);
|
|
333
|
+
}
|
|
327
334
|
}
|
|
328
335
|
}
|
|
329
336
|
async postHistory(req, fetchNew) {
|
|
@@ -337,7 +344,7 @@ export class QueryExpress {
|
|
|
337
344
|
}
|
|
338
345
|
}
|
|
339
346
|
init(req) {
|
|
340
|
-
this.query(req).
|
|
347
|
+
this.query(req).model = this.param;
|
|
341
348
|
}
|
|
342
349
|
query(req) {
|
|
343
350
|
if (this.options.queryKey in req) {
|