Skip to content

Instantly share code, notes, and snippets.

@johncrisostomo
Created February 28, 2019 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johncrisostomo/535ca961085576674dcb0c921a68e2ba to your computer and use it in GitHub Desktop.
Save johncrisostomo/535ca961085576674dcb0c921a68e2ba to your computer and use it in GitHub Desktop.
tailing the cosmosdb change feed
const options = { startFromBeginning: true };
const { headers } = await container.items.create({ ... });
const lsn = headers["lsn"];
const options = { continuation: lsn };
const options = {};
const options = { startTime: new Date() }; // any Date object will do
const changeFeed = container.items.readChangeFeed(partitionKey, options);
npm install --save @azure/cosmos
while (changeFeed.hasMoreResults) {
const { result } = await changeFeed.executeNext();
// do what you want with the result / changes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment