mongodb - What is the easiest way to check for record with two criteria, insert if it doesn't exist, if one or multiple exist, update them all -
A cursed time is taking me to do a query.
Building_id, username and correct.
We need to see that there is a record for a user and a particular building (because they can only have one vote).
If it does not exist, then we need it to enter a new record with Building_ID, username and correct.
If this is present, then we have to find the record of building_id and usernames and correct updates to be the new vote.
I am playing with saving, updating, receiving or receiving, and they keep popping up all the errors, how will this be done in Mongoengin?
You can use a simple update, set upset and correct many :
Syntax is similar to:
db.collection.update (& lt; query & gt ;, & lt; update & Gt; Upgrade: & lt; boolean & gt; Multi: & lt; boolean & gt;}) Regarding the investigation of two criteria, the amount of as much as you want in your query Might be possible. I do not know its collection, but may be:
db.yourCollection.update ({"user": "some users", "build indead" : "Some Building ID"}, {"true": "your correction"}, {upert: true, multiple: true})
Comments
Post a Comment