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
Post a Comment