Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Feb 12, 2024
1 parent eb449c4 commit e80cff1
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,6 @@ Document.prototype.$__init = function(doc, opts) {
init(this, doc, this._doc, opts);

markArraySubdocsPopulated(this, opts.populated);

this.$emit('init', this);
this.constructor.emit('init', this);

Expand All @@ -703,7 +702,6 @@ Document.prototype.$__init = function(doc, opts) {
null;

applyDefaults(this, this.$__.selected, this.$__.exclude, hasIncludedChildren, false, this.$__.skipDefaults);

return this;
};

Expand Down Expand Up @@ -746,7 +744,6 @@ function init(self, obj, doc, opts, prefix) {
}
path = prefix + i;
schemaType = docSchema.path(path);

// Should still work if not a model-level discriminator, but should not be
// necessary. This is *only* to catch the case where we queried using the
// base model and the discriminated model has a projection
Expand Down
2 changes: 1 addition & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3830,6 +3830,7 @@ Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, op
* @param {Object|String|String[]} [projection] optional projection containing which fields should be selected for this document
* @param {Object} [options] optional options
* @param {Boolean} [options.setters=false] if true, apply schema setters when hydrating
* @param {Boolean} [options.hydratedPopulatedDocs=false] if true, populates the docs if passing pre-populated data
* @return {Document} document instance
* @api public
*/
Expand All @@ -3843,7 +3844,6 @@ Model.hydrate = function(obj, projection, options) {
}
obj = applyProjection(obj, projection);
}

const document = require('./queryHelpers').createModel(this, obj, projection);
document.$init(obj, options);
return document;
Expand Down
1 change: 1 addition & 0 deletions test/model.hydrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('model', function() {
const company = { _id: new mongoose.Types.ObjectId(), name: 'Booster', users: [users[0]] };

const C = Company.hydrate(company, null, { hydratedPopulatedDocs: true });
console.log('what is C', C);
assert.equal(C.users[0].name, 'Val');
});
});
Expand Down

0 comments on commit e80cff1

Please sign in to comment.