Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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}`);
}
}
exports.getValue = function(path, obj, map) {
return mpath.get(path, obj, '_doc', map);
};
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
}
exports.getValue = function (path, obj, map) {
return mpath.get(path, obj, '_doc', map);
}
exports.getValue = function(path, obj, map) {
return mpath.get(path, obj, '_doc', map);
};
exports.getValue = function (path, obj, map) {
return mpath.get(path, obj, '_doc', map);
}
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;
}
exports.getValue = function(path, obj, map) {
return mpath.get(path, obj, '_doc', map);
};
exports.getValue = function(path, obj, map) {
return mpath.get(path, obj, '_doc', map);
};
_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");
}
}