cosmosdb mongo api对于某些命令不起作用

编程入门 行业动态 更新时间:2024-10-12 08:20:45
本文介绍了cosmosdb mongo api对于某些命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Azure上的 cosmosdb 因为我正在使用 mongodb api 我有一个请求" 集合,里面有一个声明" 数组

I am using cosmosdb on azure In that I am using mongodb api I have a "request" collection inside that there is a "claims" array

如果我使用此命令:

db.getCollection('requests').find({"claims.id": 1002})

它不适用于cosmosdb mongo api,但适用于我托管的本地mongo服务实例.

It is not working in cosmosdb mongo api but working for local mongo service instance I have hosted.

我的请求对象如下

{ "_id" : NumberLong(1001), "claims" : [ { "type" : "broadband", "id" : NumberLong(1002), "createdOn" : NumberLong(1462799667905) } ] }

推荐答案

并非所有MongoDB的查询语法/功能都已实现.似乎是这种情况.

Not all of MongoDB's query syntax / capabilities are implemented. This appears to be such a case.

但是,这种轻微的解决方法应该对您有用-我刚刚在自己的CosmosDB(MongoDB API)集合中对其进行了测试:

However, this slight workaround should work for you - I just tested it on my own CosmosDB (MongoDB API) collection:

db.getCollection('request').find({claims: { $elemMatch: { id:1002 }}}).pretty() { "_id" : 1001, "claims" : [ { "type" : "broadband", "id" : 1002, "createdOn" : NumberLong("1462799667905") } ] }

请注意,您也可以呼叫db.request.find()而不需要呼叫getCollection().

Note that you can also call db.request.find() without the need for a call to getCollection().

更多推荐

cosmosdb mongo api对于某些命令不起作用

本文发布于:2023-11-23 01:13:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619573.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   命令   cosmosdb   mongo   api

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!