Permalink
Browse files

fix: add a toBSON to documents for easier querying

Fix #4866
  • Loading branch information...
1 parent ab680e4 commit dd8003b1b9dd89543ce5f52aa2c912f093a9bdde @vkarpov15 vkarpov15 committed Jan 12, 2017
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/document.js
View
@@ -273,6 +273,19 @@ Document.prototype.$__buildDoc = function(obj, fields, skipId) {
return doc;
};
+/*!
+ * Converts to POJO when you use the document for querying
+ */
+
+Document.prototype.toBSON = function() {
+ return this.toObject({
+ transform: false,
+ virtuals: false,
+ _skipDepopulateTopLevel: true,
+ depopulate: true
+ });
+};
+
/**
* Initializes the document without setters or marking anything modified.
*

0 comments on commit dd8003b

Please sign in to comment.