These are chat archives for Automattic/mongoose

Jul 2018
Lenny Khazan
Jul 30 2018 15:27
What's the best way to access isModified/modifiedPaths in a post-save hook? Looks like it only has the values set in a pre-save hook, but I want my hook to only run if the save executes successfully.
Mihajlo Ilijić
Jul 30 2018 22:47
@LK the way I do it is to have pre-save hook which will attach the flag to the document and then access it in the post-save hook
like this:
// pre-save hook
this.wasNameModified = this.isModified('name')

// ...
// later, in post-save hook
if (this.wasNameModified) {
  // do something
this property won't be saved to the DB, so you won't have to worry about that
Jul 30 2018 23:52
:tada: We just released version 5.2.6 :tada:

5.2.6 / 2018-07-30

  • fix(document): don't double-call deeply nested custom getters when using get() #6779 #6637
  • fix(query): upgrade mquery for readConcern() helper #6777
  • docs(schematypes): clean up typos #6773 sajadtorkamani
  • refactor(browser): fix webpack warnings #6771 #6705
  • fix(populate): make error reported when no localField specified catchable #6767
  • docs(connection): use correct form in createConnection example #6766 lineus
  • fix(connection): throw helpful error when using legacy mongoose.connect() syntax #6756
  • fix(document): handle overwriting $session in execPopulate() #6754
  • fix(query): propagate top-level session down to populate() #6754
  • fix(aggregate): add session() helper for consistency with query api #6752
  • fix(map): avoid infinite recursion when update overwrites a map #6750
  • fix(model): be consistent about passing noop callback to mongoose.model() init() as well as db.model() #6707