0
這裏一個MongoDB的記錄MongoDB的需要ID給每個元素
{
_id : ObjectId("4e77bb3b8a3e000000004f7a"),
when : Date("2011-09-19T02:10:11.3Z",
author : "alex",
title : "No Free Lunch",
text : "This is the text of the post. It could be very long.",
tags : [ "business", "ramblings" ],
votes : 5,
voters : [ "jane", "joe", "spencer", "phyllis", "li" ],
comments : [
{ who : "jane", when : Date("2011-09-19T04:00:10.112Z"),
comment : "I agree." },
{ who : "meghan", when : Date("2011-09-20T14:36:06.958Z"),
comment : "You must be joking. etc etc ..." }
]
}
現在的JSON表示我有一個問題,如果我想從comments
數組中刪除任何評論的比我該怎麼辦呢?
我不想依賴評論文本。
是否有任何工具可以爲文檔中的每個對象賦予id。
不,MongoDB只給一個文檔一個id。爲了讓你的數組中有一個對象的id,你必須自己做。 –
我想通過使用java,如果我添加id到每個元素由自己比我想編碼更多的管理該ID。你知道任何符合我的標準的nosql數據庫? –
_id是對象的** ID ** – Crazyshezy