|
Create, Read, Update and Delete Operations
Performing Modifications: Basic Document Updates
How do you update a single document?
.
- Using update({query},{update})
Can you update multiple documents?
.
- Yes: using update({query},{update},{upsert},{multi => TRUE}
- If multi is TRUE, all documents matching query are updated
- Default value of multi = FALSE
What basic update operators are available?
.
- Basic: $inc, $set, $unset, $rename, $setOnInsert
- More info: docs.mongodb.org/manual/reference/operator/update/#id1
Can you save and update?
.
- Using save() or update({query},{update},TRUE)
- If _id is unique a new document is saved
- If _id matches the existing document is updated
- A new document is added if the upsert parameter of update() is TRUE
|
|