Comparing version
@@ -0,1 +1,5 @@ | ||
3.1.2 / 2018-08-01 | ||
================== | ||
* chore: move eslint to devDependencies #110 [jakesjews](https://github.com/jakesjews) | ||
3.1.1 / 2018-07-30 | ||
@@ -2,0 +6,0 @@ ================== |
@@ -224,3 +224,3 @@ 'use strict'; | ||
* | ||
* @param {String} readConcern | ||
* @param {String|Object} concern | ||
*/ | ||
@@ -227,0 +227,0 @@ |
{ | ||
"name": "mquery", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "Expressive query building for MongoDB", | ||
@@ -21,3 +21,2 @@ "main": "lib/mquery.js", | ||
"debug": "3.1.0", | ||
"eslint": "4.14.0", | ||
"regexp-clone": "0.0.1", | ||
@@ -27,2 +26,3 @@ "sliced": "1.0.1" | ||
"devDependencies": { | ||
"eslint": "^4.14.0", | ||
"istanbul": "^0.4.5", | ||
@@ -29,0 +29,0 @@ "mocha": "4.1.0", |
118
README.md
@@ -53,3 +53,3 @@ # mquery | ||
- [findOneAndUpdate](#findoneandupdate) | ||
- [findOneAndRemove](#findoneandremove) | ||
- [findOneAndDelete, findOneAndRemove](#findoneandremove) | ||
- [distinct](#distinct) | ||
@@ -94,2 +94,3 @@ - [exec](#exec) | ||
- [hint](#hint) | ||
- [j](#j) | ||
- [limit](#limit) | ||
@@ -100,7 +101,9 @@ - [maxScan](#maxscan) | ||
- [sort](#sort) | ||
- [read](#read) | ||
- [readConcern](#readconcern) | ||
- [read, setReadPreference](#read) | ||
- [readConcern, r](#readconcern) | ||
- [slaveOk](#slaveok) | ||
- [snapshot](#snapshot) | ||
- [tailable](#tailable) | ||
- [writeConcern, w](#writeconcern) | ||
- [wtimeout, wTimeout](#wtimeout) | ||
@@ -293,3 +296,4 @@ ## Helpers | ||
Declares this query a _findAndModify_ with remove query. Optionally pass a match clause, options, or callback. If a callback is passed, the query is executed. | ||
Declares this query a _findAndModify_ with remove query. Alias of findOneAndDelete. | ||
Optionally pass a match clause, options, or callback. If a callback is passed, the query is executed. | ||
@@ -305,2 +309,3 @@ When executed, the first matching document (if found) is modified according to the update document, removed from the collection and passed to the callback. | ||
```js | ||
A.where().findOneAndDelete() | ||
A.where().findOneAndRemove() | ||
@@ -868,2 +873,23 @@ A.where().findOneAndRemove(match) | ||
### j() | ||
Requests acknowledgement that this operation has been persisted to MongoDB's on-disk journal. | ||
This option is only valid for operations that write to the database: | ||
- `deleteOne()` | ||
- `deleteMany()` | ||
- `findOneAndDelete()` | ||
- `findOneAndUpdate()` | ||
- `remove()` | ||
- `update()` | ||
- `updateOne()` | ||
- `updateMany()` | ||
Defaults to the `j` value if it is specified in [writeConcern](#writeconcern) | ||
```js | ||
mquery().j(true); | ||
``` | ||
### limit() | ||
@@ -954,2 +980,4 @@ | ||
mquery().read('n') // same as nearest | ||
mquery().setReadPreference('primary') // alias of .read() | ||
``` | ||
@@ -996,16 +1024,26 @@ | ||
```js | ||
// local | ||
mquery().readConcern('local') | ||
mquery().readConcern('l') // same as local | ||
mquery().readConcern('l') | ||
mquery().r('l') | ||
// available | ||
mquery().readConcern('available') | ||
mquery().readConcern('a') // same as available | ||
mquery().readConcern('a') | ||
mquery().r('a') | ||
// majority | ||
mquery().readConcern('majority') | ||
mquery().readConcern('m') // same as majority | ||
mquery().readConcern('m') | ||
mquery().r('m') | ||
// linearizable | ||
mquery().readConcern('linearizable') | ||
mquery().readConcern('lz') // same as linearizable | ||
mquery().readConcern('lz') | ||
mquery().r('lz') | ||
// snapshot | ||
mquery().readConcern('snapshot') | ||
mquery().readConcern('s') // same as snapshot | ||
mquery().readConcern('s') | ||
mquery().r('s') | ||
``` | ||
@@ -1031,2 +1069,41 @@ | ||
### writeConcern() | ||
Sets the writeConcern option for the query. | ||
This option is only valid for operations that write to the database: | ||
- `deleteOne()` | ||
- `deleteMany()` | ||
- `findOneAndDelete()` | ||
- `findOneAndUpdate()` | ||
- `remove()` | ||
- `update()` | ||
- `updateOne()` | ||
- `updateMany()` | ||
```js | ||
mquery().writeConcern(0) | ||
mquery().writeConcern(1) | ||
mquery().writeConcern({ w: 1, j: true, wtimeout: 2000 }) | ||
mquery().writeConcern('majority') | ||
mquery().writeConcern('m') // same as majority | ||
mquery().writeConcern('tagSetName') // if the tag set is 'm', use .writeConcern({ w: 'm' }) instead | ||
mquery().w(1) // w is alias of writeConcern | ||
``` | ||
##### Write Concern: | ||
writeConcern({ w: `<value>`, j: `<boolean>`, wtimeout: `<number>` }`) | ||
- the w option to request acknowledgement that the write operation has propagated to a specified number of mongod instances or to mongod instances with specified tags | ||
- the j option to request acknowledgement that the write operation has been written to the journal | ||
- the wtimeout option to specify a time limit to prevent write operations from blocking indefinitely | ||
Can be break down to use the following syntax: | ||
mquery().w(`<value>`).j(`<boolean>`).wtimeout(`<number>`) | ||
Read more about how to use write concern [here](https://docs.mongodb.com/manual/reference/write-concern/) | ||
### slaveOk() | ||
@@ -1074,2 +1151,25 @@ | ||
### wtimeout() | ||
Specifies a time limit, in milliseconds, for the write concern. If `w > 1`, it is maximum amount of time to | ||
wait for this write to propagate through the replica set before this operation fails. The default is `0`, which means no timeout. | ||
This option is only valid for operations that write to the database: | ||
- `deleteOne()` | ||
- `deleteMany()` | ||
- `findOneAndDelete()` | ||
- `findOneAndUpdate()` | ||
- `remove()` | ||
- `update()` | ||
- `updateOne()` | ||
- `updateMany()` | ||
Defaults to `wtimeout` value if it is specified in [writeConcern](#writeconcern) | ||
```js | ||
mquery().wtimeout(2000) | ||
mquery().wTimeout(2000) | ||
``` | ||
## Helpers | ||
@@ -1076,0 +1176,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
245121
3.56%4
-20%6291
2.74%1376
7.84%4
33.33%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed