开发者

Get the hit row in MongoDb

Let us say we have the next JSON structure:

{
   {
      name:"FirstComponent",
      items:[
         {
            Caption:"Item1",
            Value:"1"
         },
         {
            Caption:"Item2",
            Value:"3"
         },
         {
            Caption:"Item3",
            Value:"2"
         }
      ]
   }
}

Let us say we query for the item with value "2". {"items.Value":"2"} and we would get the whole document back. What I want to have is an index of subdocument it hit on, it would be nice from my scenar开发者_JAVA技巧io.

Is there a way to get some indication on which is the first document which hit the search?


No, that wouldn't make sense: where would it store the index in the document it returns to you?

You need to just scan the array again in C# to find the index if you really need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜