【发布时间】:2015-05-27 12:47:18
【问题描述】:
我是 Spring Data mongodb 的新手,但我只是坚持,如何使用 mongo 存储库为嵌入式文档编写基于 json 的查询。
我的数据库看起来像
"_id" : ObjectId("5565ad670cf25cbd975ab2d9"),
"_class" : "com.samepinch.domain.metadata.Metadata",
"preferenceType" : "shopping",
"subtypes" : [
{
"_id" : ObjectId("5565ad670cf25cbd975ab2d2"),
"subType" : "veg",
"preferencePoint" : 0
},
{
"_id" : null,
"subType" : "nonveg",
"preferencePoint" : 0
}
],
"createdDate" : ISODate("2015-05-27T11:41:27.357Z"),
"updatedDate" : ISODate("2015-05-27T11:41:27.357Z")
我想根据顶级文档 id 更新子类型,我必须为 id 为 5565ad670cf25cbd975ab2d2 的子类型更新preferencePoint ,如何为此编写查询?
【问题讨论】:
标签: java mongodb spring-boot spring-data-mongodb