我是Spring框架的新手.我有我的mongo文件
{
"_id" : ObjectId("527242d584ae917d8bd75c7b"),
"postTitle" : "Car",
"postDesc" : "rent",
"owner" : ObjectId("526a588f84aed6f41cca10bd"),
"intrest" : []
}
Run Code Online (Sandbox Code Playgroud)
我想要的是搜索有id的文件
"_id" : ObjectId("527242d584ae917d8bd75c7b")
Run Code Online (Sandbox Code Playgroud)
并将其更新为
{
"_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")
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的域名是
@Document
public class Post {
@Id
private ObjectId _id;
private String postTitle;
private String postDesc;
private ObjectId owner=Global.getCurruser();
private List<Intrest> intrest = …Run Code Online (Sandbox Code Playgroud) 我想更新GrifFs文件集合中的单个元数据字段.
我阅读了有关Spring Data MongoDB的文档,但没有找到任何API.
到目前为止,我发现的唯一解决方案是直接使用Mongo API删除现有文件,并存储一个新文件_id.但这不是有效的解决方案.该问题特定于Spring Data MongoDB.任何替代?