Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating Mongo doc in scala using cashbah

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..

like image 484
Sumit D Avatar asked Dec 19 '25 20:12

Sumit D


1 Answers

Try this It worked fine for me

coll.update(query1,$set("status"->0)) 

Where query1 is your search query

like image 83
Prashant Thorat Avatar answered Dec 21 '25 15:12

Prashant Thorat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!