Skip to content

Commit

Permalink
Update samples and readme (Azure#27311)
Browse files Browse the repository at this point in the history
### Packages impacted by this PR
@azure/cosmos

### Issues associated with this PR
Azure#27273 

### Describe the problem that is addressed by this PR
Fix typos in readme and samples of change feed.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_
N/A

### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
  • Loading branch information
amanrao23 authored Oct 3, 2023
1 parent 28cbcd0 commit 893fcb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions sdk/cosmosdb/cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,28 +269,28 @@ There are four starting positions for change feed:
```js
// Signals the iterator to read changefeed from the beginning of time.
const options = {
changeFeedStartFrom: ChangeFeedStartFrom.Beginning();
}
changeFeedStartFrom: ChangeFeedStartFrom.Beginning(),
};
const iterator = container.getChangeFeedIterator(options);
```

- `Time`

```js
// Signals the iterator to read changefeed from a particular point of time.
const time = new Date("2023/09/11") // some sample date
const time = new Date("2023/09/11"); // some sample date
const options = {
changeFeedStartFrom: ChangeFeedStartFrom.Time(time);
}
changeFeedStartFrom: ChangeFeedStartFrom.Time(time),
};
```

- `Now`

```js
// Signals the iterator to read changefeed from this moment onward.
const options = {
changeFeedStartFrom: ChangeFeedStartFrom.Now();
}
changeFeedStartFrom: ChangeFeedStartFrom.Now(),
};
```

- `Continuation`
Expand All @@ -299,8 +299,8 @@ const options = {
// Signals the iterator to read changefeed from a saved point.
const continuationToken = "some continuation token recieved from previous request";
const options = {
changeFeedStartFrom: ChangeFeedStartFrom.Continuation(continuationToken);
}
changeFeedStartFrom: ChangeFeedStartFrom.Continuation(continuationToken),
};
```

Here's an example of fetching change feed for a partition key
Expand All @@ -318,6 +318,7 @@ while (iterator.hasMoreResults) {
// process this response
}
```

Because the change feed is effectively an infinite list of items that encompasses all future writes and updates, the value of `hasMoreResults` is always `true`. When you try to read the change feed and there are no new changes available, you receive a response with `NotModified` status.

More detailed usage guidelines and examples of change feed can be found [here](https://learn.microsoft.com/azure/cosmos-db/nosql/change-feed-pull-model?tabs=javascript).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @summary Demonstrates using a ChangeFeed for an epk range
*/

dotenv.config();
require("dotenv").config();

const { finish, handleError, logSampleHeader } = require("../Shared/handleError");
const {
Expand Down

0 comments on commit 893fcb3

Please sign in to comment.