你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

列表集合

对特定数据库的集合资源(即 colls URI 路径)执行 GET 将返回数据库中集合的列表。

注意

这些 API 参考文章介绍如何使用 Azure Cosmos DB 数据平面 API 创建资源。 使用数据平面 API,可以配置基本选项,例如索引策略、分区键,就像使用 Cosmos DB SDK 一样。 如果需要对所有 Azure Cosmos DB 资源提供完整的功能支持,建议使用 Cosmos DB 资源提供程序

请求

方法 请求 URI 说明
GET https://{databaseaccount}.documents.azure.com/dbs/{db-id}/colls {databaseaccount} 是在订阅下创建的 Azure Cosmos DB 帐户的名称。 {db-id} 值是用户生成的数据库名称/ID,而不是系统生成的 id (rid) 。

标头

有关所有 Cosmos DB 请求 使用的标头,请参阅常见的 Azure Cosmos DB REST 请求标头。

正文

无。

响应

列表集合返回指定数据库中的集合数组。

标头

有关所有 Cosmos DB 响应 返回的标头,请参阅常见的 Azure Cosmos DB REST 响应标头。

状态代码

下表列出了此操作返回的常见状态代码。 有关状态代码的完整列表,请参阅 HTTP 状态代码

HTTP 状态代码 说明
200 正常 操作成功。

正文

属性 说明
_摆脱 此属性是集合所在的数据库的资源 ID。
_计数 此属性显示作为列表操作的一部分返回的连接数。
DocumentCollections 此属性是包含作为列表操作的一部分返回的集合的数组。 有关集合中包含的属性的详细信息,请参阅 集合
{  
  "_rid": "PaYSAA==",  
  "DocumentCollections": [  
    {  
      "id": "SampleCollection",  
      "indexingPolicy": {  
        "indexingMode": "consistent",  
        "automatic": true,  
        "includedPaths": [  
          {  
            "path": "/*",  
            "indexes": [  
              {  
                "kind": "Range",  
                "dataType": "Number",  
                "precision": -1  
              },  
              {  
                "kind": "Hash",  
                "dataType": "String",  
                "precision": 3  
              }  
            ]  
          }  
        ],  
        "excludedPaths": []  
      },  
      "_rid": "PaYSAPH7qAo=",  
      "_ts": 1459194239,  
      "_self": "dbs/PaYSAA==/colls/PaYSAPH7qAo=/",  
      "_etag": "\"00001300-0000-0000-0000-56f9897f0000\"",  
      "_docs": "docs/",  
      "_sprocs": "sprocs/",  
      "_triggers": "triggers/",  
      "_udfs": "udfs/",  
      "_conflicts": "conflicts/"  
    },  
    {  
      "id": "SampleCollectionWithCustomIndexPolicy",  
      "indexingPolicy": {  
        "indexingMode": "lazy",  
        "automatic": true,  
        "includedPaths": [  
          {  
            "path": "/*",  
            "indexes": [  
              {  
                "kind": "Range",  
                "dataType": "Number",  
                "precision": -1  
              },  
              {  
                "kind": "Hash",  
                "dataType": "String",  
                "precision": 3  
              }  
            ]  
          }  
        ],  
        "excludedPaths": []  
      },  
      "_rid": "PaYSAIxUPws=",  
      "_ts": 1459194241,  
      "_self": "dbs/PaYSAA==/colls/PaYSAIxUPws=/",  
      "_etag": "\"00001500-0000-0000-0000-56f989810000\"",  
      "_docs": "docs/",  
      "_sprocs": "sprocs/",  
      "_triggers": "triggers/",  
      "_udfs": "udfs/",  
      "_conflicts": "conflicts/"  
    }  
  ],  
  "_count": 2  
}  
  

示例

GET https://querydemo.documents.azure.com/dbs/SampleDatabase/colls HTTP/1.1  
x-ms.date: 04/20/2021
authorization: type%3dmaster%26ver%3d1.0%26sig%3dQdp6TjZxdeJAKSiUfG%2fd7dS46USXy1IF%2bt5ToLdvOaA%3d  
Cache-Control: no-cache  
User-Agent: Microsoft.Azure.Documents.Client/1.6.0.0Internal Azure DocumentDB Studio/0.61  
x-ms-version: 2015-12-16  
Accept: application/json  
Host: querydemo.documents.azure.com  
  
HTTP/1.1 200 Ok  
Cache-Control: no-store, no-cache  
Pragma: no-cache  
Transfer-Encoding: chunked  
Content-Type: application/json  
Content-Location: https://querydemo.documents.azure.com/dbs/SampleDatabase/colls  
Server: Microsoft-HTTPAPI/2.0  
Strict-Transport-Security: max-age=31536000  
x-ms-last-state-change-utc: Fri, 25 Mar 2016 22:55:02.762 GMT  
x-ms-resource-quota: collections=5000;  
x-ms-resource-usage: collections=27;  
x-ms-item-count: 2  
x-ms-schemaversion: 1.1  
x-ms-alt-content-path: dbs/SampleDatabase  
x-ms-content-path: PaYSAA==  
x-ms-request-charge: 2  
x-ms-serviceversion: version=1.6.52.5  
x-ms-activity-id: 9c102725-4c2b-48ba-8f51-7ac1dc6dbce7  
x-ms-session-token: M:7860  
x-ms-gatewayversion: version=1.6.52.5  
Date: Mon, 28 Mar 2016 21:25:59 GMT  
  
{  
  "_rid": "PaYSAA==",  
  "DocumentCollections": [  
    {  
      "id": "SampleCollection",  
      "indexingPolicy": {  
        "indexingMode": "consistent",  
        "automatic": true,  
        "includedPaths": [  
          {  
            "path": "/*",  
            "indexes": [  
              {  
                "kind": "Range",  
                "dataType": "Number",  
                "precision": -1  
              },  
              {  
                "kind": "Hash",  
                "dataType": "String",  
                "precision": 3  
              }  
            ]  
          }  
        ],  
        "excludedPaths": []  
      },  
      "_rid": "PaYSAPH7qAo=",  
      "_ts": 1459194239,  
      "_self": "dbs/PaYSAA==/colls/PaYSAPH7qAo=/",  
      "_etag": "\"00001300-0000-0000-0000-56f9897f0000\"",  
      "_docs": "docs/",  
      "_sprocs": "sprocs/",  
      "_triggers": "triggers/",  
      "_udfs": "udfs/",  
      "_conflicts": "conflicts/"  
    },  
    {  
      "id": "SampleCollectionWithCustomIndexPolicy",  
      "indexingPolicy": {  
        "indexingMode": "lazy",  
        "automatic": true,  
        "includedPaths": [  
          {  
            "path": "/*",  
            "indexes": [  
              {  
                "kind": "Range",  
                "dataType": "Number",  
                "precision": -1  
              },  
              {  
                "kind": "Hash",  
                "dataType": "String",  
                "precision": 3  
              }  
            ]  
          }  
        ],  
        "excludedPaths": []  
      },  
      "_rid": "PaYSAIxUPws=",  
      "_ts": 1459194241,  
      "_self": "dbs/PaYSAA==/colls/PaYSAIxUPws=/",  
      "_etag": "\"00001500-0000-0000-0000-56f989810000\"",  
      "_docs": "docs/",  
      "_sprocs": "sprocs/",  
      "_triggers": "triggers/",  
      "_udfs": "udfs/",  
      "_conflicts": "conflicts/"  
    }  
  ],  
  "_count": 2  
}  
  

另请参阅