How to use the mpath.get function in mpath

To help you get started, we’ve selected a few mpath 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 GilbertGobbels / GAwesomeBot / Database / Query.js View on Github external
prop (path) {
		try {
			if (path === "..") {
				const index = this.parsed.lastIndexOf(".");
				this.parsed = this.parsed.substring(0, index);
				this._current = this.parsed === "" ? this._doc._doc : mpath.get(this.parsed, this._doc._doc);

				this._shiftSchema(this.parsed, true);

				return this;
			}

			this.parsed += this._parseForString(path);
			this._current = mpath.get(this.parsed, this._doc._doc);
			this._shiftSchema(path);
			return this;
		} catch (err) {
			throw new GABError("GADRIVER_ERROR", { err }, `Could not parse Query: ${err.message}`);
		}
	}
github dinubs / jam-api / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function(path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
};
github cvent / lounge / lib / cbdocument.utils.js View on Github external
const indexType = indexes[v].indexType

      let value = null
      if (indexes[v].compound) {
        value = _.map(path, p => processValue(mpath.get(p, data)))
        value = expandValues(value)
        value = _.compact(value)

        const containsNested = _.some(value, _.isArray)
        if (containsNested) {
          value = _.map(value, v => v.join('_'))
        } else {
          value = value.join('_')
        }
      } else {
        value = processValue(mpath.get(path, data))
      }

      ret[name] = {
        path,
        value,
        name,
        indexType
      }
    }
  }

  return ret
}
github legomushroom / iconmelon / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function (path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
}
github joshlobaptista / Barista-Fullstack / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function(path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
};
github KIDx / GzhuOJ / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function (path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
}
github GilbertGobbels / GAwesomeBot / Database / Query.js View on Github external
inc (path, amount) {
		if (amount === undefined && typeof path === "string") amount = 1;
		if (path === undefined && amount === undefined) path = 1;

		if (amount !== undefined) {
			const parsed = this.parsed + this._parseForString(path);
			const value = mpath.get(parsed, this._doc) + amount;
			if (isNaN(value)) return this;

			const definition = this._shiftSchema(path, false, false);
			this._validate(definition, parsed, value);

			this._inc(parsed, amount);
		} else {
			const value = mpath.get(this.parsed, this._doc) + path;
			if (isNaN(value)) return this;

			this._validate(this._definition, this.parsed, value);

			this._inc(this.parsed, path);
		}
		return this;
	}
github agabardo / nyc_restaurants / nycRestaurants / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function(path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
};
github treeandgrass / likeread / node_modules / mongoose / lib / utils.js View on Github external
exports.getValue = function(path, obj, map) {
  return mpath.get(path, obj, '_doc', map);
};
github GilbertGobbels / GAwesomeBot / Database / Query.js View on Github external
_unset (path) {
		const childPathSeparatorIndex = path.lastIndexOf(".");
		const parentPath = path.substring(0, childPathSeparatorIndex);
		const childPath = path.substring(childPathSeparatorIndex + 1);
		const parent = mpath.get(parentPath, this._doc._doc);
		if (Array.isArray(parent)) {
			parent.splice(childPath, 1);
			this._doc._setAtomic(path, "", "$unset");
		} else {
			delete parent[childPath];
			delete mpath.get(parentPath, this._doc)[childPath];
			this._doc._setAtomic(path, "", "$unset");
		}
	}

mpath

{G,S}et object values using MongoDB-like path notation

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis