访问 MongoDB Rest Service 以获取文档内的文档
激活 mongodb 和 rest 后,我想查询另一个文档中的文档,语法是什么?在我的示例中,我有一个 Person 集合,其中包含每个 Person 的 Order 文档。
例如,我有这个架构
public Person{
public int Id {get;set;}
public IList<Order> Order {get;set;}
}
public Order{
public int Id {get;set;}
public string OrderName {get;set;}
}
如果我想查询 Id = 2 的人,我只需要输入以下 URL:
http://localhost:28017/MyDatabase/PersonCollection/?filter_Id=2
但是如果我想查询 Id = 40 的订单怎么办?
http://localhost:28017/MyDatabase/PersonCollection/?filter_Order.Id=40
但它不起作用,它返回所有没有我的过滤器的订单,ID=40。
解决办法是什么?
谢谢 约翰
with mongodb and rest activated, i would like to query a document inside another document, what is the syntax ? In my exemple, I have a Person collection which contains an Order document for each Person.
Ex, I have this schema
public Person{
public int Id {get;set;}
public IList<Order> Order {get;set;}
}
public Order{
public int Id {get;set;}
public string OrderName {get;set;}
}
If I want to query the person with Id = 2, I just need to type this URL:
http://localhost:28017/MyDatabase/PersonCollection/?filter_Id=2
But what If I want to query the Order with Id = 40 ?
http://localhost:28017/MyDatabase/PersonCollection/?filter_Order.Id=40
But It doesn't work, it returns all the orders without my filter by Id=40.
What's the solution ?
Thanks
John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
语法与平常相同,因此以下请求应该有效:
但 yout 文档应如下所示:
Syntax the same as usual, so following request should work:
But yout document should looks like this: