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