我的数据有这样的结构:
{
"user": {
"name":"John",
"sports":[
{"sId":"sport1","name":"basketball"},
{"sId":"sport2",{"name":"tennis"},
{"sId":"sport3","name":"surf"}, ...
{"sId":"sportN","name":"golf"}
],
"birthDate":"25/07/1960"
}
}
我想过滤以获得相同的用户,但仅限于前两项运动,例如:
{
"user": {
"name":"John",
"sports":[
{"sId":"sport1","name":"basketball"},
{"sId":"sport2","name":"tennis"}
],
"birthDate":"25/07/1960"
}
}
然后接下来的两个,...
{
"user": {
"name":"John",
"sports":[
{"sId":"sport3","name":"surf"},
{"sId":"sport4","name":"icehockey"}
],
"birthDate":"25/07/1960"
}
}
等等
但我不知道如何在不获取整个用户的情况下在 mongo 中查询它
任何帮助,将不胜感激。先感谢您。