dsd
dsd

Reputation: 551

Reload Object after save()

I am using mongodb and mongoose. Some of the properties of the document schema that I use have defaults which are set when the document is saved. I intend to read these properties after calling the save() function of a document instance. However, the save() does not seem to apply the change to the document instance:

doc.save();
console.log(doc.somePropertySetByDefault); // undefined

Is there a way how one can do that without writing an entire query (i.e. Doc.findOne(...))?

Upvotes: 1

Views: 353

Answers (1)

dsd
dsd

Reputation: 551

The solution I found was to call doc.populate().

Upvotes: 1

Related Questions