Select from following answers:- db.Students.update({},{$inc:{available:true}})
- db.Students.update({_id:100},{$set:{available:1}})

- db.Students.update({_id:100, $set:{available:1}})
- None of the above
- All Above
The right answer is Answer 2.
The query part, {_id:100} identifies the document we want to update, and the update part, {$set:{available:1}}) sets the "available" field to 1.
db.Students.update({},{$inc:{available:true}}) is wrong because $inc only works on numbers, and true is a boolean.
db.Students.update({_id:100, $set:{available:1}}) is wrong because update expects (at least) two arguments: a query part and an update part.
Show Correct Answer
Asked In: Many Interviews |
Alert Moderator