Skip to content

Commit

Permalink
Updated Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gastonpereyra committed Dec 5, 2019
1 parent a30c440 commit ed8cebf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased
### Changed
- `save` uses `findAndModify` with `upsert: true` and `new: true`, to return always `_id`

## [1.7.1] - 2019-11-22
### Fixed
- `multiRemove` can remove multiple docs based on their IDs
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ getTotals return example:
### ***async*** `save(model, {item})`
Insert/update a item into the database.
Requires a `model [Model]` and `item [Object]`.
Returns `String` **ID** of the item *inserted* or **Unique Index** used as filter if it was *updated* or rejects if cannot.
Returns `String` **ID** of the item inserted or updated.

### ***async*** `multiSave(model, [{items}], limit)`
Insert/update multiple items into the database.
Expand Down Expand Up @@ -343,9 +343,16 @@ mongo.createIndexes(model);
}
*/

// save
// save insert
result = await mongo.save(model, {
id: 1,
unique: 1,
value: 'sarasa'
}); // expected return: '00000058faf66849077316ba'

// save update
result = await mongo.save(model, {
id: '00000058faf66849077316ba',
unique: 1,
value: 'sarasa'
}); // expected return: '00000058faf66849077316ba'

Expand Down

0 comments on commit ed8cebf

Please sign in to comment.