Container class

依識別碼讀取、取代或刪除特定現有容器的作業。

請參閱建立新容器的容器,以及讀取/查詢所有容器;使用 .containers

注意:所有這些作業都會針對固定預算進行呼叫。 您應該設計系統,讓這些呼叫以子線性方式調整您的應用程式。 例如,不要在每個單 item.read() 一呼叫之前呼叫 container(id).read() ,以確保容器存在;請在應用程式啟動時執行此動作。

屬性

conflicts

讀取和查詢指定容器衝突的作業。

若要讀取或刪除特定衝突,請使用 .conflict(id)

database
id
items

建立新專案的作業,以及讀取/查詢所有專案

若要讀取、取代或刪除現有的專案,請使用 .item(id)

範例

建立新的項目

const {body: createdItem} = await container.items.create({id: "<item id>", properties: {}});
scripts

預存程式、觸發程式和使用者定義函式的所有作業

url

傳回資源的參考 URL。 用於在 [許可權] 中連結。

方法

conflict(string, PartitionKey)

用來依識別碼讀取、取代或刪除特定的現有 衝突

用於 .conflicts 建立新的衝突,或查詢/讀取所有衝突。

delete(RequestOptions)

刪除容器

deleteAllItemsForPartitionKey(PartitionKey, RequestOptions)

刪除所有檔屬於所提供分割區索引鍵值的容器

getFeedRanges()
getPartitionKeyDefinition()

先藉由查看快取來取得分割區索引鍵定義,否則讀取集合。

getQueryPlan(string | SqlQuerySpec)
item(string, PartitionKey)

用來依識別碼讀取、取代或刪除特定的現有 專案

用於 .items 建立新專案,或查詢/讀取所有專案。

範例

取代專案 const {body: replacedItem} = await container.item("<item id>", "<partition key value>").replace({id: "<item id>", title: "Updated post", authorID: 5});

read(RequestOptions)

讀取容器的定義

readOffer(RequestOptions)

取得容器上的供應專案。 如果沒有存在,則會傳回未定義的 OfferResponse。

readPartitionKeyRanges(FeedOptions)
replace(ContainerDefinition, RequestOptions)

取代容器的定義

屬性詳細資料

conflicts

讀取和查詢指定容器衝突的作業。

若要讀取或刪除特定衝突,請使用 .conflict(id)

Conflicts conflicts

屬性值

database

database: Database

屬性值

id

id: string

屬性值

string

items

建立新專案的作業,以及讀取/查詢所有專案

若要讀取、取代或刪除現有的專案,請使用 .item(id)

範例

建立新的項目

const {body: createdItem} = await container.items.create({id: "<item id>", properties: {}});
Items items

屬性值

scripts

預存程式、觸發程式和使用者定義函式的所有作業

Scripts scripts

屬性值

url

傳回資源的參考 URL。 用於在 [許可權] 中連結。

string url

屬性值

string

方法詳細資料

conflict(string, PartitionKey)

用來依識別碼讀取、取代或刪除特定的現有 衝突

用於 .conflicts 建立新的衝突,或查詢/讀取所有衝突。

function conflict(id: string, partitionKey?: PartitionKey): Conflict

參數

id

string

衝突的識別碼。

partitionKey
PartitionKey

傳回

delete(RequestOptions)

刪除容器

function delete(options?: RequestOptions): Promise<ContainerResponse>

參數

options
RequestOptions

傳回

deleteAllItemsForPartitionKey(PartitionKey, RequestOptions)

刪除所有檔屬於所提供分割區索引鍵值的容器

function deleteAllItemsForPartitionKey(partitionKey: PartitionKey, options?: RequestOptions): Promise<ContainerResponse>

參數

partitionKey
PartitionKey

要刪除之專案的分割區索引鍵值

options
RequestOptions

傳回

getFeedRanges()

function getFeedRanges(): Promise<readonly FeedRange[]>

傳回

Promise<readonly FeedRange[]>

可以擷取變更摘要的所有摘要範圍。

getPartitionKeyDefinition()

警告

此 API 現已淘汰。

This method has been renamed to readPartitionKeyDefinition.

先藉由查看快取來取得分割區索引鍵定義,否則讀取集合。

function getPartitionKeyDefinition(): Promise<ResourceResponse<PartitionKeyDefinition>>

傳回

getQueryPlan(string | SqlQuerySpec)

function getQueryPlan(query: string | SqlQuerySpec): Promise<Response_2<PartitionedQueryExecutionInfo>>

參數

query

string | SqlQuerySpec

傳回

Promise<Response_2<PartitionedQueryExecutionInfo>>

item(string, PartitionKey)

用來依識別碼讀取、取代或刪除特定的現有 專案

用於 .items 建立新專案,或查詢/讀取所有專案。

範例

取代專案 const {body: replacedItem} = await container.item("<item id>", "<partition key value>").replace({id: "<item id>", title: "Updated post", authorID: 5});

function item(id: string, partitionKeyValue?: PartitionKey): Item

參數

id

string

Item的識別碼。

partitionKeyValue
PartitionKey

Item資料分割索引鍵的值

傳回

read(RequestOptions)

讀取容器的定義

function read(options?: RequestOptions): Promise<ContainerResponse>

參數

options
RequestOptions

傳回

readOffer(RequestOptions)

取得容器上的供應專案。 如果沒有存在,則會傳回未定義的 OfferResponse。

function readOffer(options?: RequestOptions): Promise<OfferResponse>

參數

options
RequestOptions

傳回

Promise<OfferResponse>

readPartitionKeyRanges(FeedOptions)

function readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator<PartitionKeyRange>

參數

feedOptions
FeedOptions

傳回

QueryIterator<PartitionKeyRange>

replace(ContainerDefinition, RequestOptions)

取代容器的定義

function replace(body: ContainerDefinition, options?: RequestOptions): Promise<ContainerResponse>

參數

options
RequestOptions

傳回