Had a lab update that didn't update

I was doing the lesson 2 lab in new learn.mongodb.com “CRUD Operations” course and encountered something strange.

I ran the command to push the new values into the array and it successfully completed but when I went to query the document, the new values were not there. I then ran the same update again and query again and they were there after a second update.

Here is the output from the first update that apparently did nothing even though the output says otherwise. I’ve moved on in the course but this was bugging me since I didn’t understand why this would happen. Is this just some lab environment/timing bug/issue or is this something may have procedural done wrong?

Atlas atlas-nmat34-shard-0 [primary] bird_data> db.birds.updateOne({"_id":ObjectId("6268471e613e55b82d7065d7")},
... {$push:{"diet": {$each:["newts", "opossum", "skunks", "squirrels"]}}})
  acknowledged: true,
  insertedId: null,
  matchedCount: 1,
  modifiedCount: 1,
  upsertedCount: 0
Atlas atlas-nmat34-shard-0 [primary] bird_data> db.birds.findOne({"_id": ObjectId("6268471e613e55b82d7065d7")})
  _id: ObjectId("6268471e613e55b82d7065d7"),
  common_name: 'Great Horned Owl',
  scientific_name: 'Bubo virginianus',
  wingspan_cm: 111.76,
  habitat: [ 'grasslands', 'farmland', 'tall forest' ],
  diet: [ 'mice', 'small mammals', 'rabbits', 'shrews' ],
  last_seen: ISODate("2022-05-19T20:20:44.083Z")

Thanks, -michael

Hey @MichaelB,

Thanks for bringing this to our attention. I’ll raise this issue with the concerned team who can further evaluate on why this problem is happening.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.