我正在尝试使用Mongo定义合适的文档结构。我的数据代表一个“事件”,它本身可以由N级嵌套事件组成,每个事件都有一个与之相关的时间:
{
eventName: "TopEvent",
time: "1000",
eventType: "Type1",
events:[{
eventName: "EventA1",
time: "200",
eventType: "Type2",
event: [], /* no child events */
},{
eventName: "EventB1",
time: "800",
eventType: "Type2",
event: [
{
eventName: "EventB2",
time: "500",
eventType: "Type2",
event: [], /* no child events */
},{
eventName: "EventB3",
time: "300",
eventType: "Type2",
event: [], /* no child events */
},
],
},
]
这是在Mongo中建模此信息的合适方法,以便我可以通过eventName,eventType和time找到数据(在递归的任何级别)吗?