I am attempting to update information on one of my fields where two different conditions are met. I don't know if this is the right idea on how to do it, but guidance would be appreciated. I am met with the error of: "unknown top level operator: $eq"
db.shop.update({"$and":[{"item.name":"Milk"}, {"$eq":{"item.price":2.80}}]}, {"$set": {"item.expiry":"21/10/19"}});
sushant mehta :
You can use $and as\n\ndb.shop.update(\n {\"$and\":[{\"$eq\":[\"item.name\",\"Milk\"]}, {\"$eq\":[\"item.price\",2.80]}]}, \n {\"$set\": {\"item.expiry\":\"21/10/19\"}}\n)\n\nbut it is equivalent to below and will be faster as expression takes time to compute\n\ndb.shop.update(\n {\"item.name\":\"Milk\",\"item.price\":2.80}, \n {\"$set\": {\"item.expiry\":\"21/10/19\"}}\n)\n",
2019-10-19T07:29:40