gpt4 book ai didi

mongodb - 获取属性与嵌套在数组中的值匹配的所有对象

转载 作者:可可西里 更新时间:2023-11-01 10:16:01 24 4
gpt4 key购买 nike

我有如下数据表:

{
"_id" : ObjectId("value"),
"owner" : "testuser",
"date" : ISODate("2017-03-16T12:45:03.386Z"),
"location" : "thuis",
"venue" : "bijna thuis",
"description" : "fghgfh",
"completed" : false,
"winnerName" : null,
"subscriptions" : [],
"interactions" : [
{
"_id" : ObjectId("objectid"),
"owner" : "testuser",
"type" : "guess",
"date" : ISODate("2017-03-06T12:13:10.049Z"),
"answer" : false,
"message" : "test 1"
},
{
"_id" : ObjectId("objectid"),
"owner" : "testuser",
"type" : "guess",
"date" : ISODate("2017-03-06T12:13:10.049Z"),
"answer" : false,
"message" : "test 2"
}
],
"__v" : 0,
"active" : true

以上只是一个游戏对象。这意味着我们的数据库中有几个这样的对象。我试图只获得所有者 ==“testuser”的交互。问题是我似乎无法找出最好的方法来做到这一点。在我的代码中,我有 2 个对象(Game 和 Interaction),其中 Game 有一系列交互。

我仍然可以使用 mongocsharpdriver 执行此操作吗?

在此先感谢您的所有帮助。

最佳答案

希望它对你有用谢谢:-)

collection.Find(x => x.owner == "testuser").ToList(); //where collection is MongoDB collection

关于mongodb - 获取属性与嵌套在数组中的值匹配的所有对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43370829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com