@ewb/mongoose-query-express 1.0.6 → 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.
@@ -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
- req.ewb.queryHistory.setOldDoc(this.getDoc(req).toObject());
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ewb/mongoose-query-express",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "description": "Routes and controllers for express to handle mongoose queries",
6
6
  "main": "./lib/index.js",