我刚刚开始与MongoDB在几天内,这里是我的收藏:
{
PlayerUid:1
ListData:
[
{
Id:100
ListInfo:[
{
Uid:1,
content:"Those I don't care"
},
{
Uid:2,
content:"Those I don't care"
},
{
Uid:3,
content:"Those I don't care"
},
{
Uid:4,
content:"Those I don't care"
}
]
},
{
Id:101
ListInfo:[
{
Uid:5,
content:"Which I wanted"
},
{
Uid:6,
content:"Those I don't care"
},
{
Uid:7,
content:"Those I don't care"
},
{
Uid:8,
content:"Those I don't care"
}
]
}
]
},
{
PlayerUid:2
ListData:
[
{
Id:100
ListInfo:[
{
Uid:9,
content:"Those I don't care"
},
{
Uid:10,
content:"Those I don't care"
},
{
Uid:11,
content:"Those I don't care"
},
{
Uid:12,
content:"Those I don't care"
}
]
},
{
Id:101
ListInfo:[
{
Uid:13,
content:"Those I don't care"
},
{
Uid:14,
content:"Those I don't care"
},
{
Uid:15,
content:"Those I don't care"
},
{
Uid:16,
content:"Those I don't care"
}
]
}
]
}
我想获取条件为PlayerUid = 1,Id:101,Uid = 5的数据。
我试过了
findOne({ PlayerUid: 1}, { ListData: { $elemMatch: { Id: 101 } } })
我得到了
{
ListData: [ { Id: 101, ListInfo: [Array] } ]
}
然后我就被卡住了,我不知道如何在ListInfo中获取或归档数据。
{
Uid:5,
content:"Which I wanted"
}
or
{
PlayerUid:1
ListData:
[
{
Id:100
ListInfo:
[
{
Uid:5,
content:"Which I wanted"
}
]
}
]
}
可能吗?
这是我的第一篇文章,为我在这里做错的事情道歉。
1条答案
按热度按时间rt4zxlrg1#
我已经将store构造函数更改为key-value,如
一切都很顺利。