Skip to content

Commit ff26353

Browse files
committed
readme edits
1 parent fbb2368 commit ff26353

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ docsChanges.on("error", err => {
625625
await session.saveChanges();
626626
}
627627

628-
...
628+
// ...
629629
// dispose changes instance once you're done
630630
changes.dispose();
631631

@@ -635,8 +635,9 @@ changes.dispose();
635635

636636
#### Stream documents with ID prefix
637637
```javascript
638-
// stream() returns a Readable
639638
const userStream = await session.advanced.stream("users/");
639+
// stream() method returns a Readable
640+
640641
userStream.on("data", user => {
641642
// User { name: 'Anna', id: 'users/1-A' }
642643
});
@@ -649,16 +650,17 @@ userStream.on("error", err => {
649650
```javascript
650651
// create a query
651652
const query = session.query({ collection: "users" }).whereGreaterThan("age", 29);
652-
// can get query stats passing a stats callback to stream()
653+
653654
let stats;
654655
// stream() returns a Readable
656+
// get query stats passing a stats callback to stream() method
655657
const queryStream = await session.advanced.stream(query, _ => stats = _);
656658

657659
queryStream.on("data", user => {
658660
// User { name: 'Anna', id: 'users/1-A' }
659661
});
660662

661-
// or can get stats using an event listener
663+
// get stats using an event listener
662664
queryStream.once("stats", stats => {
663665
// { resultEtag: 7464021133404493000,
664666
// isStale: false,
@@ -687,7 +689,7 @@ const user = {
687689
await session.store(user, "users/1");
688690
await session.saveChanges();
689691

690-
// modify doc to create a new revision
692+
// modify the document to create a new revision
691693
user.name = "Roman";
692694
user.age = 40;
693695
await session.saveChanges();
@@ -708,18 +710,13 @@ const revisions = await session.advanced.revisions.getFor("users/1");
708710

709711
### Suggestions
710712
```javascript
711-
// Having data:
713+
// users collection
712714
// [ User {
713715
// name: 'John',
714716
// age: 30,
715717
// registeredAt: 2017-11-10T23:00:00.000Z,
716718
// kids: [Array],
717719
// id: 'users/1-A' },
718-
// User {
719-
// name: 'Stefanie',
720-
// age: 25,
721-
// registeredAt: 2015-07-29T22:00:00.000Z,
722-
// id: 'users/2-A' } ]
723720

724721
// and a static index like:
725722
class UsersIndex extends AbstractIndexCreationTask {
@@ -742,11 +739,7 @@ const suggestionQueryResult = await session.query({ collection: "users" })
742739

743740
## Using object literals for entities
744741

745-
In order to comfortably use object literals as entities set function getting collection name based on the content of the object - `store.conventions.
746-
findCollectionNameForObjectLiteral()`. This needs to be done *before* a `initialize()` call on `DocumentStore` instance. If you fail to do so, your entites will land up in *@empty* collection having an *UUID* for an ID.
747-
748-
For example here's a function using *collection* field to set collection name:
749-
742+
In order to comfortably use object literals as entities set function getting collection name based on the content of the object - `store.conventions.findCollectionNameForObjectLiteral()`. This needs to be done *before* an `initialize()` call on `DocumentStore` instance. If you fail to do so, your entites will land up in *@empty* collection having an *UUID* for an ID. E.g.
750743
```javascript
751744
store.conventions.findCollectionNameForObjectLiteral = entity => entity["collection"];
752745
```

0 commit comments

Comments
 (0)