java - How to update a field in an entire collection in mongodb using morphia -


i have collection named teaminfo, created class in java using morphia's annotations follows:

@entity("teaminfo ") public class teaminfo {     @id     private integer teaminfoid;     private string teamname;     private integer usercount; } 

i need update operation on teaminfo changes usercount , sets 0. need query set usercount value in teaminfo documents. how teaminfo documents in query?

updateoperations<teaminfo> updateoperation = datastore.createupdateoperations(teaminfo.class).set("usercount", 0);         query<teaminfo> query = datastore. ??? ; datastore.update(query, updateoperation); 

i started learning morphia, great if can me.

you use empty query without condition.

updateoperations<teaminfo> updateoperation = datastore.createupdateoperations(teaminfo.class).set("usercount", 0);         query<teaminfo> query = datastore.createquery(getentityclazz()); // empty query datastore.update(query, updateoperation); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -