Skip to content

Commit

Permalink
use mquery public selection methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Heckmann committed Jan 9, 2014
1 parent e324846 commit 39a4bc0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/model.js
Expand Up @@ -971,7 +971,7 @@ Model.find = function find (conditions, fields, options, callback) {
// get the raw mongodb collection object // get the raw mongodb collection object
var mq = new Query({}, options, this, this.collection); var mq = new Query({}, options, this, this.collection);
mq.select(fields); mq.select(fields);
if (this.schema.discriminatorMapping && mq._selectedInclusively()) { if (this.schema.discriminatorMapping && mq.selectedInclusively()) {
mq.select(this.schema.options.discriminatorKey); mq.select(this.schema.options.discriminatorKey);
} }


Expand Down Expand Up @@ -1076,7 +1076,7 @@ Model.findOne = function findOne (conditions, fields, options, callback) {
// get the mongodb collection object // get the mongodb collection object
var mq = new Query({}, options, this, this.collection); var mq = new Query({}, options, this, this.collection);
mq.select(fields); mq.select(fields);
if (this.schema.discriminatorMapping && mq._selectedInclusively()) { if (this.schema.discriminatorMapping && mq.selectedInclusively()) {
mq.select(this.schema.options.discriminatorKey); mq.select(this.schema.options.discriminatorKey);
} }


Expand Down
39 changes: 29 additions & 10 deletions lib/query.js
Expand Up @@ -2812,21 +2812,40 @@ Query.prototype.centerSphere = function () {
} }


/** /**
* Determines if query fields are inclusive * Determines if field selection has been made.
* *
* @return {Boolean} bool defaults to true * @method selected
* @api private * @memberOf Query
* @return {Boolean}
* @api public
*/ */


Query.prototype._selectedInclusively = Query.prototype.selectedInclusively; /**

* Determines if inclusive field selection has been made.
/*! *
* Remove from public api for 3.8 * query.selectedInclusively() // false
* query.select('name')
* query.selectedInclusively() // true
*
* @method selectedInclusively
* @memberOf Query
* @return {Boolean}
* @api public
*/ */


Query.prototype.selected = /**
Query.prototype.selectedInclusively = * Determines if exclusive field selection has been made.
Query.prototype.selectedExclusively = undefined; *
* query.selectedExclusively() // false
* query.select('-name')
* query.selectedExclusively() // true
* query.selectedInclusively() // false
*
* @method selectedExclusively
* @memberOf Query
* @return {Boolean}
* @api public
*/


/*! /*!
* Export * Export
Expand Down

0 comments on commit 39a4bc0

Please sign in to comment.