Item class
Belirli bir öğe üzerinde işlem gerçekleştirmek için kullanılır.
Tüm öğelerdeki işlemler için bkz. Öğeleri; bkz. container.items.
Özellikler
| container | |
| id | |
| url | Kaynağa bir başvuru URL'si döndürür. İzinler'de bağlantı için kullanılır. |
Yöntemler
| delete<T>(Request |
Öğeyi silin. Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı. Örnek
|
| patch<T>(Patch |
Öğe üzerinde JSONPatch gerçekleştirin. Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı. Örnek
|
| read<T>(Request |
Öğenin tanımını okuyun. Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir.
Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı.
T türü bir sınıfsa, eşleşme prototipi olmayacağından JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir. Örnek Yanıt için özel tür kullanma
|
| replace(Item |
Öğenin tanımını değiştirin. JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir. Örnek
|
| replace<T>(T, Request |
Öğenin tanımını değiştirin. Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı. JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir. Örnek
|
Özellik Ayrıntıları
container
id
id: string
Özellik Değeri
string
url
Kaynağa bir başvuru URL'si döndürür. İzinler'de bağlantı için kullanılır.
string url
Özellik Değeri
string
Yöntem Ayrıntıları
delete<T>(RequestOptions)
Öğeyi silin.
Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı.
Örnek
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
interface TodoItem {
title: string;
done: boolean;
id: string;
}
const { resource: item } = await container.item("id", "<pkValue>").read<TodoItem>();
await container.item("id").delete<TodoItem>();
function delete<T>(options?: RequestOptions): Promise<ItemResponse<T>>
Parametreler
- options
- RequestOptions
İstek için ek seçenekler
Döndürülenler
Promise<ItemResponse<T>>
patch<T>(PatchRequestBody, RequestOptions)
Öğe üzerinde JSONPatch gerçekleştirin.
Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı.
Örnek
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
interface TodoItem {
title: string;
done: boolean;
id: string;
}
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const { resource: item } = await container.item("id", "<pkValue>").read<TodoItem>();
const { resource: patchedItem } = await container.item("id").patch<TodoItem>([
{
op: "replace", // Operation type (can be replace, add, remove, set, incr)
path: "/title", // The path to the property to update
value: "new-title", // New value for the property
},
{
op: "remove",
path: "/done",
},
]);
function patch<T>(body: PatchRequestBody, options?: RequestOptions): Promise<ItemResponse<T>>
Parametreler
- body
- PatchRequestBody
- options
- RequestOptions
İstek için ek seçenekler
Döndürülenler
Promise<ItemResponse<T>>
read<T>(RequestOptions)
Öğenin tanımını okuyun.
Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir.
Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı.
T türü bir sınıfsa, eşleşme prototipi olmayacağından typeof karşılaştırmaları geçemez.
Yalnızca arabirimlerin kullanılması önerilir.
JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir.
Örnek
Yanıt için özel tür kullanma
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
interface TodoItem {
title: string;
done: boolean;
id: string;
}
const { resource: item } = await container.item("id", "<pkValue>").read<TodoItem>();
function read<T>(options?: RequestOptions): Promise<ItemResponse<T>>
Parametreler
- options
- RequestOptions
İstek için ek seçenekler
Döndürülenler
Promise<ItemResponse<T>>
replace(ItemDefinition, RequestOptions)
Öğenin tanımını değiştirin.
JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir.
Örnek
import { CosmosClient, ItemDefinition } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const item: ItemDefinition = {
id: "id",
title: "new_title",
};
const { resource: replacedItem } = await container.item("id").replace(item);
function replace(body: ItemDefinition, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>
Parametreler
- body
- ItemDefinition
Var olan Öğetanımının değiştirilmeye uygun tanımı.
- options
- RequestOptions
İstek için ek seçenekler
Döndürülenler
Promise<ItemResponse<ItemDefinition>>
replace<T>(T, RequestOptions)
Öğenin tanımını değiştirin.
Sağlanan herhangi bir tür olan T, SDK tarafından zorunlu tutulmayabilir. Daha fazla veya daha az özellik alabilirsiniz ve bunu zorlamak sizin mantığınıza bağlı.
JSON öğeleri için ayarlanmış şema yok. Bunlar herhangi bir sayıda özel özellik içerebilir.
Örnek
import { CosmosClient } from "@azure/cosmos";
const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { database } = await client.databases.createIfNotExists({ id: "Test Database" });
const { container } = await database.containers.createIfNotExists({ id: "Test Container" });
interface TodoItem {
title: string;
done: boolean;
id: string;
}
const { resource: item } = await container.item("id", "<pkValue>").read<TodoItem>();
item.done = true;
const { resource: replacedItem } = await container.item("id").replace<TodoItem>(item);
function replace<T>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>
Parametreler
- body
-
T
Var olan Öğetanımının değiştirilmeye uygun tanımı.
- options
- RequestOptions
İstek için ek seçenekler
Döndürülenler
Promise<ItemResponse<T>>