다음을 통해 공유


Items class

새 항목을 만들고 모든 항목을 읽고 쿼리하는 작업

기존 컨테이너를 읽거나 바꾸거나 삭제하려면 항목을 참조하십시오. 사용 .item(id).

속성

container

메서드

batch(OperationInput[], PartitionKey, RequestOptions)

항목에 대한 트랜잭션 일괄 처리 작업을 실행합니다.

Batch는 작업 수행에 따라 형식화된 작업 배열을 사용합니다. Batch는 트랜잭션이며 실패할 경우 모든 작업을 롤백합니다. 선택 항목은 만들기, Upsert, 읽기, 바꾸기 및 삭제입니다.

사용 예제:

import { CosmosClient, OperationInput } 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" });

// The partitionKey is a required second argument. If it’s undefined, it defaults to the expected partition key format.
const operations: OperationInput[] = [
  {
    operationType: "Create",
    resourceBody: { id: "doc1", name: "sample", key: "A" },
  },
  {
    operationType: "Upsert",
    resourceBody: { id: "doc2", name: "other", key: "A" },
  },
];

await container.items.batch(operations, "A");
bulk(OperationInput[], BulkOptions, RequestOptions)

항목에 대해 대량 작업을 실행합니다.

changeFeed(ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

changeFeed(PartitionKey, ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

Example

변경 피드의 시작 부분에서 읽습니다.

const iterator = items.readChangeFeed({ startFromBeginning: true });
const firstPage = await iterator.fetchNext();
const firstPageResults = firstPage.result
const secondPage = await iterator.fetchNext();
changeFeed<T>(ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

changeFeed<T>(PartitionKey, ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

create<T>(T, RequestOptions)

항목을 만듭니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

항목을 만듭니다.

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" });

const { resource: createdItem } = await container.items.create({
  id: "<item id>",
  properties: {},
});
executeBulkOperations(OperationInput[], RequestOptions)

항목에 대해 대량 작업을 실행합니다.

Example

import { CosmosClient, OperationInput } 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 operations: OperationInput[] = [
  {
    operationType: "Create",
    resourceBody: { id: "doc1", name: "sample", key: "A" },
  },
  {
    operationType: "Upsert",
    partitionKey: "A",
    resourceBody: { id: "doc2", name: "other", key: "A" },
  },
];

await container.items.executeBulkOperations(operations);
getChangeFeedIterator<T>(ChangeFeedIteratorOptions)

변경 내용을 반복하는 반복기를 반환합니다. 반환된 반복기를 사용하여 단일 파티션 키, 피드 범위 또는 전체 컨테이너에 대한 변경 내용을 가져올 수 있습니다.

Example

import {
  CosmosClient,
  PartitionKeyDefinitionVersion,
  PartitionKeyKind,
  ChangeFeedStartFrom,
} 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 containerDefinition = {
  id: "Test Database",
  partitionKey: {
    paths: ["/name", "/address/zip"],
    version: PartitionKeyDefinitionVersion.V2,
    kind: PartitionKeyKind.MultiHash,
  },
};
const { container } = await database.containers.createIfNotExists(containerDefinition);

const partitionKey = "some-partition-Key-value";
const options = {
  changeFeedStartFrom: ChangeFeedStartFrom.Beginning(partitionKey),
};

const iterator = container.items.getChangeFeedIterator(options);

while (iterator.hasMoreResults) {
  const response = await iterator.readNext();
  // process this response
}
getEncryptionQueryIterator(EncryptionQueryBuilder, FeedOptions)

암호화된 컨테이너의 모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, EncryptionQueryBuilder } 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 queryBuilder = new EncryptionQueryBuilder(
  `SELECT firstname FROM Families f WHERE f.lastName = @lastName`,
);
queryBuilder.addParameter("@lastName", "Hendricks", "/lastname");
const queryIterator = await container.items.getEncryptionQueryIterator(queryBuilder);
const { resources: items } = await queryIterator.fetchAll();
query(string | SqlQuerySpec, FeedOptions)

모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, SqlQuerySpec } 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 querySpec: SqlQuerySpec = {
  query: `SELECT * FROM Families f WHERE f.lastName = @lastName`,
  parameters: [{ name: "@lastName", value: "Hendricks" }],
};
const { resources: items } = await container.items.query(querySpec).fetchAll();
query<T>(string | SqlQuerySpec, FeedOptions)

모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, SqlQuerySpec } 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 querySpec: SqlQuerySpec = {
  query: `SELECT * FROM Families f WHERE f.lastName = @lastName`,
  parameters: [{ name: "@lastName", value: "Hendricks" }],
};
const { resources: items } = await container.items.query(querySpec).fetchAll();
readAll(FeedOptions)

모든 항목을 읽습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

배열에 대한 모든 항목을 읽습니다.

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" });

const { resources: containerList } = await container.items.readAll().fetchAll();
readAll<T>(FeedOptions)

모든 항목을 읽습니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

배열에 대한 모든 항목을 읽습니다.

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" });

const { resources: containerList } = await container.items.readAll().fetchAll();
readChangeFeed(ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

readChangeFeed(PartitionKey, ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

Example

변경 피드의 시작 부분에서 읽습니다.

const iterator = items.readChangeFeed({ startFromBeginning: true });
const firstPage = await iterator.fetchNext();
const firstPageResults = firstPage.result
const secondPage = await iterator.fetchNext();
readChangeFeed<T>(ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

readChangeFeed<T>(PartitionKey, ChangeFeedOptions)

변경 내용을 반복하는 ChangeFeedIterator 만들기

upsert(unknown, RequestOptions)

항목을 Upsert합니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

upsert<T>(T, RequestOptions)

항목을 Upsert합니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

항목을 Upsert합니다.

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" });

const { resource: createdItem1 } = await container.items.create({
  id: "<item id 1>",
  properties: {},
});

const { resource: upsertItem1 } = await container.items.upsert({
  id: "<item id 1>",
  updated_properties: {},
});

const { resource: upsertItem2 } = await container.items.upsert({
  id: "<item id 2>",
  properties: {},
});

속성 세부 정보

container

container: Container

속성 값

메서드 세부 정보

batch(OperationInput[], PartitionKey, RequestOptions)

항목에 대한 트랜잭션 일괄 처리 작업을 실행합니다.

Batch는 작업 수행에 따라 형식화된 작업 배열을 사용합니다. Batch는 트랜잭션이며 실패할 경우 모든 작업을 롤백합니다. 선택 항목은 만들기, Upsert, 읽기, 바꾸기 및 삭제입니다.

사용 예제:

import { CosmosClient, OperationInput } 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" });

// The partitionKey is a required second argument. If it’s undefined, it defaults to the expected partition key format.
const operations: OperationInput[] = [
  {
    operationType: "Create",
    resourceBody: { id: "doc1", name: "sample", key: "A" },
  },
  {
    operationType: "Upsert",
    resourceBody: { id: "doc2", name: "other", key: "A" },
  },
];

await container.items.batch(operations, "A");
function batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise<Response<OperationResponse[]>>

매개 변수

operations

OperationInput[]

작업 목록입니다. 제한 100

partitionKey
PartitionKey
options
RequestOptions

요청을 수정하는 데 사용됨

반환

Promise<Response<OperationResponse[]>>

bulk(OperationInput[], BulkOptions, RequestOptions)

경고

이 API는 이제 사용되지 않습니다.

Use executeBulkOperations instead.

Bulk takes an array of Operations which are typed based on what the operation does. The choices are: Create, Upsert, Read, Replace, and Delete

Usage example:

import { CosmosClient, OperationInput } 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" });

// partitionKey is optional at the top level if present in the resourceBody
const operations: OperationInput[] = [
  {
    operationType: "Create",
    resourceBody: { id: "doc1", name: "sample", key: "A" },
  },
  {
    operationType: "Upsert",
    partitionKey: "A",
    resourceBody: { id: "doc2", name: "other", key: "A" },
  },
];

await container.items.bulk(operations);

항목에 대해 대량 작업을 실행합니다.

function bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise<BulkOperationResponse>

매개 변수

operations

OperationInput[]

작업 목록입니다. 제한 100

bulkOptions
BulkOptions

대량 동작을 수정하는 선택적 옵션 개체입니다. { continueOnError: false }를 전달하여 작업이 실패할 때 실행을 중지합니다. (기본값은 true)입니다.

options
RequestOptions

요청을 수정하는 데 사용됩니다.

반환

changeFeed(ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>

매개 변수

changeFeedOptions
ChangeFeedOptions

반환

changeFeed(PartitionKey, ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

Example

변경 피드의 시작 부분에서 읽습니다.

const iterator = items.readChangeFeed({ startFromBeginning: true });
const firstPage = await iterator.fetchNext();
const firstPageResults = firstPage.result
const secondPage = await iterator.fetchNext();
function changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>

매개 변수

partitionKey
PartitionKey
changeFeedOptions
ChangeFeedOptions

반환

changeFeed<T>(ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function changeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>

매개 변수

changeFeedOptions
ChangeFeedOptions

반환

changeFeed<T>(PartitionKey, ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function changeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>

매개 변수

partitionKey
PartitionKey
changeFeedOptions
ChangeFeedOptions

반환

create<T>(T, RequestOptions)

항목을 만듭니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

항목을 만듭니다.

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" });

const { resource: createdItem } = await container.items.create({
  id: "<item id>",
  properties: {},
});
function create<T>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>

매개 변수

body

T

항목의 본문을 나타냅니다. 사용자 정의 속성의 수를 포함할 수 있습니다.

options
RequestOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

Promise<ItemResponse<T>>

executeBulkOperations(OperationInput[], RequestOptions)

항목에 대해 대량 작업을 실행합니다.

Example

import { CosmosClient, OperationInput } 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 operations: OperationInput[] = [
  {
    operationType: "Create",
    resourceBody: { id: "doc1", name: "sample", key: "A" },
  },
  {
    operationType: "Upsert",
    partitionKey: "A",
    resourceBody: { id: "doc2", name: "other", key: "A" },
  },
];

await container.items.executeBulkOperations(operations);
function executeBulkOperations(operations: OperationInput[], options?: RequestOptions): Promise<BulkOperationResult[]>

매개 변수

operations

OperationInput[]

작업 목록

options
RequestOptions

요청을 수정하는 데 사용됩니다.

반환

Promise<BulkOperationResult[]>

작업에 해당하는 작업 결과 목록

getChangeFeedIterator<T>(ChangeFeedIteratorOptions)

변경 내용을 반복하는 반복기를 반환합니다. 반환된 반복기를 사용하여 단일 파티션 키, 피드 범위 또는 전체 컨테이너에 대한 변경 내용을 가져올 수 있습니다.

Example

import {
  CosmosClient,
  PartitionKeyDefinitionVersion,
  PartitionKeyKind,
  ChangeFeedStartFrom,
} 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 containerDefinition = {
  id: "Test Database",
  partitionKey: {
    paths: ["/name", "/address/zip"],
    version: PartitionKeyDefinitionVersion.V2,
    kind: PartitionKeyKind.MultiHash,
  },
};
const { container } = await database.containers.createIfNotExists(containerDefinition);

const partitionKey = "some-partition-Key-value";
const options = {
  changeFeedStartFrom: ChangeFeedStartFrom.Beginning(partitionKey),
};

const iterator = container.items.getChangeFeedIterator(options);

while (iterator.hasMoreResults) {
  const response = await iterator.readNext();
  // process this response
}
function getChangeFeedIterator<T>(changeFeedIteratorOptions?: ChangeFeedIteratorOptions): ChangeFeedPullModelIterator<T>

매개 변수

changeFeedIteratorOptions
ChangeFeedIteratorOptions

반환

getEncryptionQueryIterator(EncryptionQueryBuilder, FeedOptions)

암호화된 컨테이너의 모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, EncryptionQueryBuilder } 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 queryBuilder = new EncryptionQueryBuilder(
  `SELECT firstname FROM Families f WHERE f.lastName = @lastName`,
);
queryBuilder.addParameter("@lastName", "Hendricks", "/lastname");
const queryIterator = await container.items.getEncryptionQueryIterator(queryBuilder);
const { resources: items } = await queryIterator.fetchAll();
function getEncryptionQueryIterator(queryBuilder: EncryptionQueryBuilder, options?: FeedOptions): Promise<QueryIterator<ItemDefinition>>

매개 변수

queryBuilder
EncryptionQueryBuilder

작업에 대한 쿼리 구성입니다. 암호화된 속성에 대한 쿼리를 빌드하는 방법에 대한 자세한 내용은 SqlQuerySpec 을 참조하세요.

options
FeedOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

query(string | SqlQuerySpec, FeedOptions)

모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, SqlQuerySpec } 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 querySpec: SqlQuerySpec = {
  query: `SELECT * FROM Families f WHERE f.lastName = @lastName`,
  parameters: [{ name: "@lastName", value: "Hendricks" }],
};
const { resources: items } = await container.items.query(querySpec).fetchAll();
function query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<any>

매개 변수

query

string | SqlQuerySpec

작업에 대한 쿼리 구성입니다. 쿼리를 구성하는 방법에 대한 자세한 내용은 SqlQuerySpec 을 참조하세요.

options
FeedOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

query<T>(string | SqlQuerySpec, FeedOptions)

모든 항목을 쿼리합니다.

Example

배열에 대한 모든 항목을 읽습니다.

import { CosmosClient, SqlQuerySpec } 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 querySpec: SqlQuerySpec = {
  query: `SELECT * FROM Families f WHERE f.lastName = @lastName`,
  parameters: [{ name: "@lastName", value: "Hendricks" }],
};
const { resources: items } = await container.items.query(querySpec).fetchAll();
function query<T>(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<T>

매개 변수

query

string | SqlQuerySpec

작업에 대한 쿼리 구성입니다. 쿼리를 구성하는 방법에 대한 자세한 내용은 SqlQuerySpec 을 참조하세요.

options
FeedOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

readAll(FeedOptions)

모든 항목을 읽습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

배열에 대한 모든 항목을 읽습니다.

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" });

const { resources: containerList } = await container.items.readAll().fetchAll();
function readAll(options?: FeedOptions): QueryIterator<ItemDefinition>

매개 변수

options
FeedOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

readAll<T>(FeedOptions)

모든 항목을 읽습니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

배열에 대한 모든 항목을 읽습니다.

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" });

const { resources: containerList } = await container.items.readAll().fetchAll();
function readAll<T>(options?: FeedOptions): QueryIterator<T>

매개 변수

options
FeedOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

readChangeFeed(ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>

매개 변수

changeFeedOptions
ChangeFeedOptions

반환

readChangeFeed(PartitionKey, ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

Example

변경 피드의 시작 부분에서 읽습니다.

const iterator = items.readChangeFeed({ startFromBeginning: true });
const firstPage = await iterator.fetchNext();
const firstPageResults = firstPage.result
const secondPage = await iterator.fetchNext();
function readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>

매개 변수

partitionKey
PartitionKey
changeFeedOptions
ChangeFeedOptions

반환

readChangeFeed<T>(ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function readChangeFeed<T>(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>

매개 변수

changeFeedOptions
ChangeFeedOptions

반환

readChangeFeed<T>(PartitionKey, ChangeFeedOptions)

경고

이 API는 이제 사용되지 않습니다.

Use getChangeFeedIterator instead.

변경 내용을 반복하는 ChangeFeedIterator 만들기

function readChangeFeed<T>(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>

매개 변수

partitionKey
PartitionKey
changeFeedOptions
ChangeFeedOptions

반환

upsert(unknown, RequestOptions)

항목을 Upsert합니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

function upsert(body: unknown, options?: RequestOptions): Promise<ItemResponse<ItemDefinition>>

매개 변수

body

unknown

항목의 본문을 나타냅니다. 사용자 정의 속성의 수를 포함할 수 있습니다.

options
RequestOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

upsert<T>(T, RequestOptions)

항목을 Upsert합니다.

제공된 모든 형식 T는 반드시 SDK에 의해 적용되지 않습니다. 더 많거나 적은 속성을 얻을 수 있으며 이를 적용하는 것은 논리에 달려 있습니다.

JSON 항목에 대한 집합 스키마가 없습니다. 여기에는 사용자 지정 속성이 포함될 수 있습니다.

Example

항목을 Upsert합니다.

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" });

const { resource: createdItem1 } = await container.items.create({
  id: "<item id 1>",
  properties: {},
});

const { resource: upsertItem1 } = await container.items.upsert({
  id: "<item id 1>",
  updated_properties: {},
});

const { resource: upsertItem2 } = await container.items.upsert({
  id: "<item id 2>",
  properties: {},
});
function upsert<T>(body: T, options?: RequestOptions): Promise<ItemResponse<T>>

매개 변수

body

T

항목의 본문을 나타냅니다. 사용자 정의 속성의 수를 포함할 수 있습니다.

options
RequestOptions

요청을 수정하는 데 사용됩니다(예: 파티션 키 지정).

반환

Promise<ItemResponse<T>>