Comparing version
@@ -0,1 +1,7 @@ | ||
3.1.0 / 2018-07-29 | ||
================== | ||
* feat: add `readConcern()` helper #105 [Fonger](https://github.com/Fonger) | ||
* feat: add `maxTimeMS()` as alias of `maxTime()` #105 [Fonger](https://github.com/Fonger) | ||
* feat: add `collation()` helper #105 [Fonger](https://github.com/Fonger) | ||
3.0.1 / 2018-07-02 | ||
@@ -2,0 +8,0 @@ ================== |
@@ -214,3 +214,42 @@ 'use strict'; | ||
/** | ||
* Read Concern helper (mongo 3.2 drivers support this) | ||
* | ||
* Allows using string to specify read concern level: | ||
* | ||
* local 3.2+ | ||
* available 3.6+ | ||
* majority 3.2+ | ||
* linearizable 3.4+ | ||
* snapshot 4.0+ | ||
* | ||
* @param {String} readConcern | ||
*/ | ||
exports.readConcern = function readConcern (concern) { | ||
if ('string' === typeof concern) { | ||
switch (concern) { | ||
case 'l': | ||
concern = 'local' | ||
break; | ||
case 'a': | ||
concern = 'available'; | ||
break; | ||
case 'm': | ||
concern = 'majority'; | ||
break; | ||
case 'lz': | ||
concern = 'linearizable'; | ||
break; | ||
case 's': | ||
concern = 'snapshot'; | ||
break; | ||
} | ||
concern = { level: concern } | ||
} | ||
return concern | ||
} | ||
/** | ||
* Object.prototype.toString.call helper | ||
@@ -307,3 +346,3 @@ */ | ||
exports.cloneBuffer = function (buff) { | ||
var dupe = new Buffer(buff.length); | ||
var dupe = Buffer.alloc(buff.length); | ||
buff.copy(dupe, 0, 0, buff.length); | ||
@@ -310,0 +349,0 @@ return dupe; |
{ | ||
"name": "mquery", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Expressive query building for MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "lib/mquery.js", |
@@ -87,2 +87,3 @@ # mquery | ||
- [batchSize](#batchsize) | ||
- [collation](#collation) | ||
- [comment](#comment) | ||
@@ -93,5 +94,7 @@ - [hint](#hint) | ||
- [maxTime](#maxtime) | ||
- [maxTimeMS](#maxtime) | ||
- [skip](#skip) | ||
- [sort](#sort) | ||
- [read](#read) | ||
- [readConcern](#readconcern) | ||
- [slaveOk](#slaveok) | ||
@@ -826,2 +829,12 @@ - [snapshot](#snapshot) | ||
### collation() | ||
Specifies the collation option. | ||
```js | ||
query.collation({ locale: "en_US", strength: 1 }) | ||
``` | ||
[MongoDB documentation](https://docs.mongodb.com/manual/reference/method/cursor.collation/#cursor.collation) | ||
### comment() | ||
@@ -881,2 +894,3 @@ | ||
query.maxTime(100) | ||
query.maxTimeMS(100) | ||
``` | ||
@@ -971,2 +985,42 @@ | ||
### readConcern() | ||
Sets the readConcern option for the query. | ||
```js | ||
mquery().readConcern('local') | ||
mquery().readConcern('l') // same as local | ||
mquery().readConcern('available') | ||
mquery().readConcern('a') // same as available | ||
mquery().readConcern('majority') | ||
mquery().readConcern('m') // same as majority | ||
mquery().readConcern('linearizable') | ||
mquery().readConcern('lz') // same as linearizable | ||
mquery().readConcern('snapshot') | ||
mquery().readConcern('s') // same as snapshot | ||
``` | ||
##### Read Concern Level: | ||
- `local` - The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back). (MongoDB 3.2+) | ||
- `available` - The query returns from the instance with no guarantee guarantee that the data has been written to a majority of the replica set members (i.e. may be rolled back). (MongoDB 3.6+) | ||
- `majority` - The query returns the data that has been acknowledged by a majority of the replica set members. The documents returned by the read operation are durable, even in the event of failure. (MongoDB 3.2+) | ||
- `linearizable` - Read from a secondary if available, otherwise read from the primary. (MongoDB 3.4+) | ||
- `snapshot` - The query returns data that reflects all successful majority-acknowledged writes that completed prior to the start of the read operation. The query may wait for concurrently executing writes to propagate to a majority of replica set members before returning results. (MongoDB 4.0+) | ||
Aliases | ||
- `l` local | ||
- `a` available | ||
- `m` majority | ||
- `lz` linearizable | ||
- `s` snapshot | ||
Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/). | ||
### slaveOk() | ||
@@ -973,0 +1027,0 @@ |
@@ -106,3 +106,3 @@ | ||
var buf = new Buffer('hi'); | ||
var buf = Buffer.from('hi'); | ||
var binary= new mongo.Binary(buf, 2); | ||
@@ -133,3 +133,3 @@ var clone = utils.clone(binary); | ||
it('handles buffers', function(done){ | ||
var buff = new Buffer(10); | ||
var buff = Buffer.alloc(10); | ||
buff.fill(1); | ||
@@ -136,0 +136,0 @@ var clone = utils.clone(buff); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
234412
3.08%6123
2.43%1274
4.43%