These are chat archives for Automattic/mongoose

18th
Jul 2018
Bruno Barros
@bybrunobarros
Jul 18 2018 14:06
Hey everyone! I have a basic question, I guess, but I can't answer it.
Here is an Organization schema followed by an update. Unfortunately meta.stats isn't updated. item.stats contains the right data and the document is found. Could you tell me what I'm missing, please?
const OrganizationSchema = new Schema({
  publicId: String,
  meta: {
    stats: {
      // some properties
    }
  }

Organization.findOneAndUpdate({publicId: item.publicId}, {'meta.stats': item.data})
Kev
@lineus
Jul 18 2018 14:07
what version of mongoose are you using @bybrunobarros ?
there was a bug that was just fixed recently related to using positional syntax in updates
Bruno Barros
@bybrunobarros
Jul 18 2018 14:08
@lineus 5.0.15
Ok I'll try the last version, seems to be 5.2.4
Nope it didn't change the result
Bruno Barros
@bybrunobarros
Jul 18 2018 14:19
My bad, mongoose is in a private package and this package wasn't up to date :)
@lineus thanks for your help!
Kev
@lineus
Jul 18 2018 14:20
I had just finished that when you got it worked out hehe
Bruno Barros
@bybrunobarros
Jul 18 2018 14:21
Well sorry to make you work for "nothing" ;)
Kev
@lineus
Jul 18 2018 14:22
it's good practice to work through all of the silly mistakes I make when I'm doing this stuff quickly!