ChangeFeedPullModelIterator interface
Bölüm anahtarı, akış aralığı veya kapsayıcının tamamı için tüm değişiklikleri yineleyebilecek bir yineleyici döndürmek için Items.getChangeFeedIterator() kullanın.
Özellikler
| has |
Her zaman true döndürür, değişiklik akışı sonsuz bir akıştır. |
Yöntemler
| get |
Değişiklik akışı sonuçları verecek zaman uyumsuz bir yineleyici alır. Örnek Bundan sonra kapsayıcının tamamı için değişiklik akışı alma
|
| read |
Değişiklik akışı için sonraki sonuç kümesini döndürür. Örnek
|
Özellik Ayrıntıları
hasMoreResults
Her zaman true döndürür, değişiklik akışı sonsuz bir akıştır.
hasMoreResults: boolean
Özellik Değeri
boolean
Yöntem Ayrıntıları
getAsyncIterator()
Değişiklik akışı sonuçları verecek zaman uyumsuz bir yineleyici alır.
Örnek
Bundan sonra kapsayıcının tamamı için değişiklik akışı alma
import { CosmosClient, 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 { container } = await database.containers.createIfNotExists({ id: "Test Container" });
const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() };
for await (const results of container.items.getChangeFeedIterator(options).getAsyncIterator()) {
// Process result
for (const resource of results.result) {
console.log(resource);
}
}
function getAsyncIterator(): AsyncIterable<ChangeFeedIteratorResponse<(T & Resource)[]>>
Döndürülenler
AsyncIterable<ChangeFeedIteratorResponse<(T & Resource)[]>>
readNext()
Değişiklik akışı için sonraki sonuç kümesini döndürür.
Örnek
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 readNext(): Promise<ChangeFeedIteratorResponse<(T & Resource)[]>>
Döndürülenler
Promise<ChangeFeedIteratorResponse<(T & Resource)[]>>