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