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

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -