How to use the mquery.canMerge function in mquery

To help you get started, we’ve selected a few mquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github onehilltech / blueprint / packages / blueprint-gatekeeper / node_modules / mongoose / lib / query.js View on Github external
}

  // make sure we don't send in the whole Document to merge()
  if (conditions instanceof Document) {
    conditions = conditions.toObject();
  }

  if (options) {
    this.setOptions(options);
  }

  if (fields) {
    this.select(fields);
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  prepareDiscriminatorCriteria(this);

  try {
    this.cast(this.model);
    this._castError = null;
  } catch (err) {
    this._castError = err;
  }

  if (!callback) {
    // already merged in the conditions, don't need to send them in.
    return Query.base.findOne.call(this);
  }
github sx1989827 / DOClever / Server / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.find = function(conditions, callback) {
  if (typeof conditions === 'function') {
    callback = conditions;
    conditions = {};
  }

  conditions = utils.toObject(conditions);

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);

    prepareDiscriminatorCriteria(this);
  } else if (conditions != null) {
    this.error(new ObjectParameterError(conditions, 'filter', 'find'));
  }

  // if we don't have a callback, then just return the query object
  if (!callback) {
    return Query.base.find.call(this);
  }

  this._find(callback);

  return this;
};
github skepticfx / domstorm / node_modules / mongoose / lib / query.js View on Github external
}

  // make sure we don't send in the whole Document to merge()
  if (conditions instanceof Document) {
    conditions = conditions.toObject();
  }

  if (options) {
    this.setOptions(options);
  }

  if (fields) {
    this.select(fields);
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  prepareDiscriminatorCriteria(this);

  try {
    this.cast(this.model);
    this._castError = null;
  } catch (err) {
    this._castError = err;
  }

  if (!callback) {
    // already merged in the conditions, don't need to send them in.
    return Query.base.findOne.call(this);
  }
github linxixuan / linxixuan-blog / node_modules / mongoose / lib / query.js View on Github external
}

  // make sure we don't send in the whole Document to merge()
  if (conditions instanceof Document) {
    conditions = conditions.toObject();
  }

  if (options) {
    this.setOptions(options);
  }

  if (fields) {
    this.select(fields);
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  prepareDiscriminatorCriteria(this);

  try {
    this.cast(this.model);
    this._castError = null;
  } catch (err) {
    this._castError = err;
  }

  if (!callback) {
    // already merged in the conditions, don't need to send them in.
    return Query.base.findOne.call(this);
  }
github YourTradingSystems / EasyERP / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.find = function (conditions, callback) {
  if ('function' == typeof conditions) {
    callback = conditions;
    conditions = {};
  } else if (conditions instanceof Document) {
    conditions = conditions.toObject();
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  prepareDiscriminatorCriteria(this);

  try {
    this.cast(this.model);
    this._castError = null;
  } catch (err) {
    this._castError = err;
  }

  // if we don't have a callback, then just return the query object
  if (!callback) {
    return Query.base.find.call(this);
  }
github Automattic / mongoose / lib / query.js View on Github external
Query.prototype.deleteOne = function(filter, callback) {
  if (typeof filter === 'function') {
    callback = filter;
    filter = null;
  }

  filter = utils.toObject(filter);

  if (mquery.canMerge(filter)) {
    this.merge(filter);

    prepareDiscriminatorCriteria(this);
  } else if (filter != null) {
    this.error(new ObjectParameterError(filter, 'filter', 'deleteOne'));
  }

  if (!callback) {
    return Query.base.deleteOne.call(this);
  }

  this._deleteOne.call(this, callback);

  return this;
};
github sx1989827 / DOClever / Server / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.deleteMany = function(filter, callback) {
  if (typeof filter === 'function') {
    callback = filter;
    filter = null;
  }

  filter = utils.toObject(filter);

  if (mquery.canMerge(filter)) {
    this.merge(filter);

    prepareDiscriminatorCriteria(this);
  } else if (filter != null) {
    this.error(new ObjectParameterError(filter, 'filter', 'deleteMany'));
  }

  if (!callback) {
    return Query.base.deleteMany.call(this);
  }

  return this._deleteMany.call(this, callback);
};
github onehilltech / blueprint / packages / blueprint-gatekeeper / src / server / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.count = function (conditions, callback) {
  if ('function' == typeof conditions) {
    callback = conditions;
    conditions = undefined;
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  this.op = 'count';
  if (!callback) {
    return this;
  }

  this._count(callback);

  return this;
}
github skepticfx / domstorm / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.count = function (conditions, callback) {
  if ('function' == typeof conditions) {
    callback = conditions;
    conditions = undefined;
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  try {
    this.cast(this.model);
  } catch (err) {
    callback(err);
    return this;
  }

  return Query.base.count.call(this, {}, callback);
}
github joshlobaptista / Barista-Fullstack / node_modules / mongoose / lib / query.js View on Github external
Query.prototype.count = function(conditions, callback) {
  if (typeof conditions === 'function') {
    callback = conditions;
    conditions = undefined;
  }

  if (mquery.canMerge(conditions)) {
    this.merge(conditions);
  }

  this.op = 'count';
  if (!callback) {
    return this;
  }

  this._count(callback);

  return this;
};

mquery

Expressive query building for MongoDB

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis