java - how to write (or) update in MongoDB Update Query -


When I update a relation database using Hibernate, I issue a statement like this:
   

query query = getSession ( ). CreateQuery ("Update User Set isLocked = 0 where userId =: userID"); Query.setParameter ("userID", userID);

How do I do the same thing with the collection in MongoDB?

This is an example with the original mongodb-java-driver:

 < Code> DBcine Coal coll = db.getCollection ("user"); // DB Connection Example DBObject Search = New BasicDBObject ("userId", userId); DBObject Data = New BasicDBObject ("$ Set", New BasicDBObject ("isLocked", 0)); Coll.update (search, data);    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -