Im brand new to MongoDb and Morphia and
trying to learn how to update my document.
I do not see / do not understand how to do this on this page:
http://www.mongodb.org
My document is as follows: (there might be some error here)
@Entity public class UserData { private Date creationDate; private Date lastUpdateDate; @Id private ObjectId id; public String status= ""; public String uUid= ""; public UserData() { super(); this.statistic = new Statistic(); this.friendList = new FriendList(); } @Embedded private Statistic statistic; @Embedded private FriendList friendList; @PrePersist public void prePersist() { this.creationDate = (creationDate == null) ? new Date() : creationDate; this.lastUpdateDate = (lastUpdateDate == null) ? creationDate : new Date(); } }
On this page I do not see the place where they describe how to update my UserData
that has a specific uUid
Like update UserData.status
if uUid=123567
Here is what I think I should use:
ops=datastore.createUpdateOperations(UserData.class).update("uUid").if uuid=foo..something more here..
// Default update morphia - update the entire UserData document to update the selected ones.
datastore.update(datastore.createQuery(UserData.class), ops);
source share