My sample doc in mongodb is:
{ "_id" : 3, "name" : "sachin", "profilepic" : "images/pics/3.jpg" }
{ "_id" : 1, "name" : "sumit", "profilepic" : "images/pics/2.jpg" }
I want to append status:0 to the doc whose name is "sachin". I am new to scala. I write the code
val query1=MongoDBObject("name"->"sachin")
val query= MongoDBObject(status->0)
coll.update(query1,query)
But it doesn't work..
Try this It worked fine for me
coll.update(query1,$set("status"->0))
Where query1 is your search query
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With