微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

MongoDB 和 C# 查找计数

如何解决MongoDB 和 C# 查找计数

我是 mongo 和所有 nosql 数据库的新手。 是时候为我学习 sql 数据库的 arriva 了。 我创建了两个文档

  1. 玩家

    { "id": "string","matches": [ { "timeMatch": "string","matchID": "string","opponentName": "string","playerPoint": 0,"opponentPoint": 0 } ] }

2 匹配

{  "matchID": "string","boards": [ {
  "round_mum": 0,"board": [
    {
      "hexName": "string","who": "string","round": 0,"score": 0,"multiplier": 0,"color": 0,"status": 0
    }
  ]
}]}

我需要从玩家开始通过matchID加入mnatches获得这种结果:

"id": "AAAA","matches": "BBBBB" with count of Boards
"matches": "CCCCC" with count of Boards
"matches": "ddddD" with count of Boards

有可能吗? 我尝试使用计数查找,但我最好的结果是在没有计数的情况下获得整个文档

我用过这样的:

var docs = MNGPlayerMatchDataCollection.Aggregate()
                    .Lookup("MatchDataTest","MatchID","id",@as: "match")
                    //.Group("$match")
                    .Unwind("match")
                    //.Count()f
                    .As<BsonDocument>()
                    .ToEnumerable();

感谢帮助

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。