JSON 描述在 Azure Cosmos/Document DB 中查询文档的条件的对象选择器

JSON object selector to describe the criteria for querying documents in Azure Cosmos/ Document DB

我正在使用 Javascript Azure 函数绑定到 CosmosDB(文档数据库)并查询集合中的文档。我希望 SELECT 查询基于将出现在请求正文中的 JSON 对象。 IBM Cloudant 提供了一项功能,您可以在其中传递 JSON 对象(选择器)来描述选择文档的条件。我如何在 Azure 中实现同样的目标?

JSON 选择器看起来像这样-

{
  "selector": {
  "id": {
          "$gt": 0
        },
  USERS": {
            "username": "Jack",
            "department": "HR"
            }
  }
}

sql-from-mongo npm 包提供了将类似于这些的表达式转换为 CosmosDB SQL。该模块可以轻松加载到您的 Azure Functions 中,甚至可以通过一些操作将其加载到存储过程中。

完全披露:我是 npm 包的作者。