Im完全新的MongoDb和Morphia和
试图学习如何更新我的文档。morphia和howto更新现有的文档字段
我不能看到/明白如何从这个页面做:
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
像update UserData.status
如果uUid=123567
这就是我想我应该用:
ops=datastore.createUpdateOperations(UserData.class).update("uUid").if uuid=foo..something more here..
//吗啡默认的更新是更新所有的UserData文档,如何更新选定
datastore.update(datastore.createQuery(UserData.class), ops);
是的,为什么我不提及那个网页有这些信息。或者我错过了它,或者这不是解决集合内部文档的正常方式? – Erik