为了账号安全,请及时绑定邮箱和手机立即绑定

如何通过 json 中的深场在 mongo 排序中获得 20 个文档?

如何通过 json 中的深场在 mongo 排序中获得 20 个文档?

Go
FFIVE 2022-06-01 15:46:08
我在 MongoDB 中的文档:{  "_id": {    "$oid": "5e90276937b54857689435733"  },  "user_id": "",  "nickname": "",  "platform": ""  "invites": {    "$numberInt": ""  },  "hide_game_stats": false,  "game_data": {    "player_info": {      "level": {        "value": {          "$numberInt": "96"        },        "rank_icon_url": ""      },      "platform": "battle"    },    "warzone": {      "battle_royale": {        "timePlayed": {          "$numberInt": "55789"        },        "score": {          "value": {            "$numberDouble": "202485"          }        },        "kd_ratio": {          "value": {            "$numberDouble": "1.71"          }        },        "kills": {          "value": {            "$numberInt": "217"          }        },        "games_played": {          "value": {            "$numberInt": "43"          }        },        "score_per_minute": {          "value": {            "$numberDouble": "217.77"          }        },        "contracts": {          "value": {            "$numberInt": "41"          }        },        "wins": {          "value": {            "$numberInt": "2"          }        },        "top_5": {          "value": {            "$numberInt": "7"          }        },        "top_10": {          "value": {            "$numberInt": "15"          }        },        "top_25": {          "value": {            "$numberInt": "39"          }        },        "win_rate": {          "value": {            "$numberDouble": "4.7"          }        }      },      "plunder": {        "timePlayed": {          "$numberInt": "18526"        },        "cash": {          "value": {            "$numberInt": "1158"          }        },        "score": {          "value": {            "$numberDouble": "67551"          }        },        "kd_ratio": {          "value": {            "$numberDouble": "1.99"          }        },      }    }  }}我只需要 20 个文档排序game_data.warzone.battle_royale.kills.value请告诉我,我该怎么做
查看完整描述

1 回答

?
翻阅古今

TA贡献1780条经验 获得超5个赞

您不要在排序中使用 $match 操作:

findOptions.SetSort(bson.D{{"game_data.warzone.battle_royale.kills.value", -1}})


查看完整回答
反对 回复 2022-06-01
  • 1 回答
  • 0 关注
  • 105 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号