首页 \ 问答 \ 查询文档中的特定对象和可视化 - MongoDB [重复](Querying for specific objects in a document & Visualization - MongoDB [duplicate])

查询文档中的特定对象和可视化 - MongoDB [重复](Querying for specific objects in a document & Visualization - MongoDB [duplicate])

这个问题在这里已有答案:

我有一个复杂的geojson文档存储在我的MongoDB中。 我的目标是检索适用于我的条件的对象,例如:

我想在'features.properties.name'字段中检索包含“avenue”的对象。 我试过这个: db.LineString.find({'features.properties.name' : "Avenue"})结果如下:

在此处输入图像描述

如您所见,这将返回整个文档。 我的目标只是返回像突出显示的object 0满足给定条件的object 0 。 此外,结果可能以某种方式可视化?


This question already has an answer here:

I have a complex geojson document stored in my MongoDB. My goal is to retrieve the objects that apply to my condition e.g:

I want to retrieve the objects that contain "avenue" in the 'features.properties.name'field. I have tried this: db.LineString.find({'features.properties.name' : "Avenue"}) which results:

enter image description here

As you can see, this returns the entire document. My goal is just to return the objects like the highlighted object 0 which fulfil the given condition. Also, could the results be visualized somehow?


原文:https://stackoverflow.com/questions/33285735
更新时间:2021-09-14 10:09

最满意答案

如果它对当前页面很重要,请避免麻烦并使用Javascript解决方案

您也可以在ASP.NET中执行此操作。 在分页之后从数据集中获取所需的数据(因此第7页的记录为350到400),然后从以下内容更改绑定:

// do this
gv.DataSource = pagedDataSet.OrderBy(d => d.NameOfField);

// instead of
gv.DataSource = pagedDataSet;

如果你有动态列,或者不想为每个可能的属性写这个; 在这个答案中看到我的解决方案


If it just matters for the current page, avoid the hassle and use a Javascript solution.

You can also do it in ASP.NET. Grab the data you want from your DataSet, after paging (so records 350 to 400 for page 7), then change your binding from something like:

// do this
gv.DataSource = pagedDataSet.OrderBy(d => d.NameOfField);

// instead of
gv.DataSource = pagedDataSet;

If you have dynamic columns, or don't want to do write this for every possible property; see my solution in this answer.

相关问答

更多
  • 只需添加此脚本: