Skip to content

Commit

Permalink
fix: replace useProjection option with $useProjection so it doesnt ge…
Browse files Browse the repository at this point in the history
…t sent to MongoDB re: Automattic/mongoose#6880
  • Loading branch information
vkarpov15 committed Aug 23, 2018
1 parent ababead commit b9f7064
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/mquery.js
Expand Up @@ -160,7 +160,6 @@ Query.prototype.toConstructor = function toConstructor() {
* - [hint](http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24hint) *
* - [slaveOk](http://docs.mongodb.org/manual/applications/replication/#read-preference) *
* - [safe](http://www.mongodb.org/display/DOCS/getLastError+Command)
* - [useProjection] use the `projection` option rather than `fields` for sending the projection to `find()` and `findOne()` for MongoDB driver >= 3.0.0
* - collection the collection to query against
*
* _* denotes a query helper method is also available_
Expand Down Expand Up @@ -1918,7 +1917,7 @@ Query.prototype.find = function(criteria, callback) {
var conds = this._conditions;
var options = this._optionsForExec();

if (this.options.useProjection) {
if (this.$useProjection) {
options.projection = this._fieldsForExec();
} else {
options.fields = this._fieldsForExec();
Expand Down Expand Up @@ -1959,7 +1958,7 @@ Query.prototype.cursor = function cursor(criteria) {
var conds = this._conditions;
var options = this._optionsForExec();

if (this.options.useProjection) {
if (this.$useProjection) {
options.projection = this._fieldsForExec();
} else {
options.fields = this._fieldsForExec();
Expand Down Expand Up @@ -2011,7 +2010,7 @@ Query.prototype.findOne = function(criteria, callback) {
var conds = this._conditions;
var options = this._optionsForExec();

if (this.options.useProjection) {
if (this.$useProjection) {
options.projection = this._fieldsForExec();
} else {
options.fields = this._fieldsForExec();
Expand Down Expand Up @@ -2829,7 +2828,7 @@ Query.prototype._findAndModify = function(type, callback) {

fields = this._fieldsForExec();
if (fields != null) {
if (this.options.useProjection) {
if (this.$useProjection) {
options.projection = this._fieldsForExec();
} else {
options.fields = this._fieldsForExec();
Expand Down Expand Up @@ -3007,7 +3006,7 @@ Query.prototype.stream = function(streamOptions) {
var conds = this._conditions;

var options = this._optionsForExec();
if (this.options.useProjection) {
if (this.$useProjection) {
options.projection = this._fieldsForExec();
} else {
options.fields = this._fieldsForExec();
Expand Down

0 comments on commit b9f7064

Please sign in to comment.