Я новый bie для весной рамки. У меня есть Монго документ какВесна Mongo Upsert вложенные документ
{
"_id" : ObjectId("527242d584ae917d8bd75c7b"),
"postTitle" : "Car",
"postDesc" : "rent",
"owner" : ObjectId("526a588f84aed6f41cca10bd"),
"intrest" : []
}
Я хочу, чтобы найти документ, имеющий ID
"_id" : ObjectId("527242d584ae917d8bd75c7b")
и обновить его до
{
"_id" : ObjectId("527242d584ae917d8bd75c7b"),
"postTitle" : "Car",
"postDesc" : "rent",
"owner" : ObjectId("526a588f84aed6f41cca10bd"),
"intrest" : [
{
"userId" : ObjectId("526a587d84aed6f41cca10bc"),
"timestamp" : ISODate("2013-10-31T11:45:25.256Z")
},
{
"userId" : ObjectId("526a587d84aed6f41cca10bc"),
"timestamp" : ISODate("2013-11-31T11:55:25.256a")
}
]
}
мой домен
@Document
public class Post {
@Id
private ObjectId _id;
private String postTitle;
private String postDesc;
private ObjectId owner=Global.getCurruser();
private List<Intrest> intrest = new ArrayList<Intrest>();
// Getters and setters
}
@Document
public class Intrest {
private ObjectId userId;
private Date timestamp;
// Getters and setters
}
Что нужно написать в объявлении d или изменить записи в массиве intrest [].
Пожалуйста, помогите.
Вы не хотите делать upsert - вы хотите сделать обновление. Upsert - это когда вы хотите вставить новый документ - похоже, вы просто хотите добавить новые значения в существующее поле. –