Skip to content

Commit 2b5e18a

Browse files
committedJul 30, 2018
fix(query): upgrade mquery for readConcern() helper
Fix #6777
1 parent 2bf81e7 commit 2b5e18a

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed
 

‎lib/query.js

+45
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,51 @@ Query.prototype.wtimeout = function wtimeout(ms) {
11411141
return this;
11421142
};
11431143

1144+
/**
1145+
* Sets the readConcern option for the query.
1146+
*
1147+
* ####Example:
1148+
*
1149+
* new Query().readConcern('local')
1150+
* new Query().readConcern('l') // same as local
1151+
*
1152+
* new Query().readConcern('available')
1153+
* new Query().readConcern('a') // same as available
1154+
*
1155+
* new Query().readConcern('majority')
1156+
* new Query().readConcern('m') // same as majority
1157+
*
1158+
* new Query().readConcern('linearizable')
1159+
* new Query().readConcern('lz') // same as linearizable
1160+
*
1161+
* new Query().readConcern('snapshot')
1162+
* new Query().readConcern('s') // same as snapshot
1163+
*
1164+
*
1165+
* ####Read Concern Level:
1166+
*
1167+
* local MongoDB 3.2+ 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).
1168+
* available MongoDB 3.6+ 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).
1169+
* majority MongoDB 3.2+ 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.
1170+
* linearizable MongoDB 3.4+ 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.
1171+
* snapshot MongoDB 4.0+ Only available for operations within multi-document transactions. Upon transaction commit with write concern "majority", the transaction operations are guaranteed to have read from a snapshot of majority-committed data.
1172+
*
1173+
* Aliases
1174+
*
1175+
* l local
1176+
* a available
1177+
* m majority
1178+
* lz linearizable
1179+
* s snapshot
1180+
*
1181+
* Read more about how to use read concern [here](https://docs.mongodb.com/manual/reference/read-concern/).
1182+
*
1183+
* @param {String} level one of the listed read concern level or their aliases
1184+
* @see mongodb https://docs.mongodb.com/manual/reference/read-concern/
1185+
* @return {Query} this
1186+
* @api public
1187+
*/
1188+
11441189
/**
11451190
* Merges another Query or conditions object into this one.
11461191
*

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"mongodb-core": "3.1.0",
2828
"mongoose-legacy-pluralize": "1.0.2",
2929
"mpath": "0.4.1",
30-
"mquery": "3.0.0",
30+
"mquery": "3.1.1",
3131
"ms": "2.0.0",
3232
"regexp-clone": "0.0.1",
3333
"sliced": "1.0.1"

‎test/query.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,9 @@ describe('Query', function() {
749749

750750
if (typeof global.Map !== 'undefined') {
751751
query = new Query({}, {}, null, p1.collection);
752-
query.sort(new global.Map().set('a', 1).set('b', 2));
752+
query.sort(new global.Map().set('a', 1).set('b', 1));
753753
assert.equal(query.options.sort.get('a'), 1);
754-
assert.equal(query.options.sort.get('b'), 2);
754+
assert.equal(query.options.sort.get('b'), 1);
755755
}
756756

757757
query = new Query({}, {}, null, p1.collection);

0 commit comments

Comments
 (0)
Please sign in to comment.