Created
February 28, 2019 04:27
-
-
Save johncrisostomo/535ca961085576674dcb0c921a68e2ba to your computer and use it in GitHub Desktop.
tailing the cosmosdb change feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = { startFromBeginning: true }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { headers } = await container.items.create({ ... }); | |
const lsn = headers["lsn"]; | |
const options = { continuation: lsn }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const options = { startTime: new Date() }; // any Date object will do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const changeFeed = container.items.readChangeFeed(partitionKey, options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save @azure/cosmos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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