我對spring數據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,我必須更新preferencePoint具有ID 5565ad670cf25cbd975ab2d2 亞型亞型,如何編寫查詢呢?
感謝快速回復,但如何將其寫在像@查詢庫(),我完全新的春天MongoDB的數據,在此先感謝 –
@PrabjotSingh我沒有太多的舒適性在春季倉庫裏面, [this](http://docs.spring.io/spring-data/mongodb/docs/1.2.x/reference/html/mongo.repositories.html)可能會有幫助 – Yogesh
好吧,那很好,我會嘗試和感謝那一個答案 –