Comparing version 4.0.0 to 4.0.1
@@ -148,2 +148,3 @@ const debug = require('debug')('cosa:db'); | ||
* @param {object} [options.findOne=false] - Should a single item be returned. | ||
* @param {object} [options.readPreference] - the read preference for the query with one of the read constants | ||
* @returns {Cursor} returns Cursor object | ||
@@ -154,2 +155,3 @@ * @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Cursor.html} | ||
* @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#count} | ||
* @see {@link https://github.com/mongodb/node-mongodb-native/blob/357cbf689735c2447bfb05d73c142f1a5b88ca91/lib/read_preference.js#L69} | ||
*/ | ||
@@ -163,3 +165,4 @@ async find(collectionName, query, options) { | ||
count: false, | ||
findOne: false | ||
findOne: false, | ||
readPreference: undefined | ||
}); | ||
@@ -179,7 +182,19 @@ query = EJSON.deserialize(query); | ||
} else if (options.findOne) { | ||
const findOptions = { projection: options.projection || options.fields, limit: options.limit, skip: options.skip, sort: options.sort }; | ||
const findOptions = { | ||
projection: options.projection || options.fields, | ||
limit: options.limit, | ||
skip: options.skip, | ||
sort: options.sort, | ||
readPreference: options.readPreference | ||
}; | ||
debug(`db.${collection.collectionName}.findOne`, query, findOptions); | ||
return collection.findOne(query, options); | ||
} else { | ||
const findOptions = { projection: options.projection || options.fields, limit: options.limit, skip: options.skip, sort: options.sort }; | ||
const findOptions = { | ||
projection: options.projection || options.fields, | ||
limit: options.limit, | ||
skip: options.skip, | ||
sort: options.sort, | ||
readPreference: options.readPreference | ||
}; | ||
debug(`db.${collection.collectionName}.find (toArray)`, query, findOptions); | ||
@@ -256,4 +271,6 @@ return collection.find(query, options); | ||
* @param {boolean} [options.explain=false] - Should should the execution plan be returned. | ||
* @param {object} [options.readPreference] - the read preference for the query | ||
* @returns {Promise} resolves with the result of the aggregation from mongo | ||
* @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#aggregate} | ||
* @see {@link https://github.com/mongodb/node-mongodb-native/blob/357cbf689735c2447bfb05d73c142f1a5b88ca91/lib/read_preference.js#L69} | ||
*/ | ||
@@ -280,4 +297,6 @@ async aggregate(collectionName, pipeline, options) { | ||
* @param {object} [options] - Optional settings see mongo documentation | ||
* @param {object} [options.readPreference] - the read preference for the query | ||
* @returns {Promise} resolves with the result of the distinct query from mongo | ||
* @see {@link http://mongodb.github.io/node-mongodb-native/3.0/api/Collection.html#distinct} | ||
* @see {@link https://github.com/mongodb/node-mongodb-native/blob/357cbf689735c2447bfb05d73c142f1a5b88ca91/lib/read_preference.js#L69} | ||
*/ | ||
@@ -284,0 +303,0 @@ async distinct(collectionName, key, query, options) { |
{ | ||
"name": "cosa", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Cosa Models for MongoDB", | ||
@@ -37,3 +37,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"bson": "~1.1.0", | ||
"bson": "~1.1.4", | ||
"clone": "^2.1.2", | ||
@@ -45,3 +45,3 @@ "debug": "^4.1.1", | ||
"@hapi/joi": "^17.1.0", | ||
"mongodb": "~3.5.4", | ||
"mongodb": "~3.5.8", | ||
"mongodb-extended-json": "~1.11.0", | ||
@@ -48,0 +48,0 @@ "object-assign": "^4.1.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58506
1404
Updatedbson@~1.1.4
Updatedmongodb@~3.5.8