共用方式為


清單集合

在特定資料庫的集合資源上執行 GET,也就是 colls URI 路徑會傳回資料庫中集合的清單。

注意

這些 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} 值是使用者產生的資料庫名稱/識別碼,而不是系統產生的識別碼 (rid) 。

標題

如需所有 Cosmos DB 要求所使用的標頭,請參閱常見的 Azure Cosmos DB REST 要求標頭

主體

無。

回應

列出集合會傳回指定資料庫內的集合陣列。

標題

如需所有 Cosmos DB 回應所傳回的標頭,請參閱 常見的 Azure Cosmos DB REST 回應標頭

狀態碼

下表列出此作業所傳回的常見狀態碼。 如需狀態碼的完整清單,請參閱 HTTP 狀態碼

HTTP 狀態碼 Description
200 確定 作業成功。

主體

屬性 Description
_擺脫 此屬性是集合所在資料庫的資源識別碼。
_計數 這個屬性會顯示隨著清單作業一起傳回的連線數目。
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  
}  
  

另請參閱