Skip to content

Commit

Permalink
ADD #143 to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Jun 6, 2017
1 parent 6f8e944 commit be43683
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs-src/RxDocument.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ This removes the document from the collection.
myDocument.remove();
```

### update()
Updates the document based on the [mongo-update-syntax](https://docs.mongodb.com/manual/reference/operator/update-field/), based on [modifyjs](https://github.com/lgandecki/modifyjs#implemented).

```js
myDocument.update({
$inc: {
age: 1 // increases age by 1
},
$set: {
fistName: 'foobar' // sets firstName to foobar
}
});
await myDocument.save();
```



### Observe $
Calling this will return an [rxjs-Observable](http://reactivex.io/rxjs/manual/overview.html#observable) which emits all change-Events belonging to this document.

Expand Down
13 changes: 13 additions & 0 deletions docs-src/RxQuery.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ const query = myCollection.find().where('age').lt(18);
const removedDocs = await query.remove();
```


## update()
Runs and [update](./RxDocument.md#update) on every RxDocument of the query-result.

```js
const query = myCollection.find().where('age').gt(18);
await query.update({
$inc: {
age: 1 // increases age of every found document by 1
}
});
```

## NOTICE: RxQuery's are immutable

Because RxDB is a reactive database, we can do heavy performance-optimisation on query-results which change over time. To be able to do this, RxQuery's have to be immutable.
Expand Down

0 comments on commit be43683

Please sign in to comment.