我对 MongoDb 和 Morphia 完全陌生,并
试图学习如何更新我的文档。
我无法从这个页面看到/理解如何做到这一点:
http ://www.mongodb.org
我的文档如下所示:(这里可能有一些错误)
@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();
}
}
UserData
在该页面上,我看不到他们描述如何更新具有特定uUid
Like update UserData.status
if的任何地方uUid=123567
这是我认为我应该使用的:
ops=datastore.createUpdateOperations(UserData.class).update("uUid").if uuid=foo..something more here..
// morphia 默认更新是更新所有的 UserData 文档,所以如何更新选中的文档
datastore.update(datastore.createQuery(UserData.class), ops);