Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (o.isVirtual && !o.justOne && !Array.isArray(rawIds[i])) {
if (rawIds[i] == null) {
rawIds[i] = [];
} else {
rawIds[i] = [rawIds[i]];
}
} else if (o.isVirtual && o.justOne && Array.isArray(rawIds[i])) {
rawIds[i] = rawIds[i][0];
}
if (o.isVirtual && docs[i].constructor.name === 'model') {
// If virtual populate and doc is already init-ed, need to walk through
// the actual doc to set rather than setting `_doc` directly
mpath.set(o.path, rawIds[i], docs[i]);
} else {
var parts = o.path.split('.');
var cur = docs[i];
for (var j = 0; j < parts.length - 1; ++j) {
if (cur[parts[j]] == null) {
cur[parts[j]] = {};
}
cur = cur[parts[j]];
}
if (docs[i].$__) {
docs[i].populated(o.path, o.allIds[i], o.allOptions);
}
utils.setValue(o.path, rawIds[i], docs[i], setValue);
}
}
}
return this;
}
let schema;
const parts = path.split('.');
if (pathType === 'adhocOrUndefined' && strict) {
// check for roots that are Mixed types
let mixed;
for (i = 0; i < parts.length; ++i) {
const subpath = parts.slice(0, i + 1).join('.');
// If path is underneath a virtual, bypass everything and just set it.
if (i + 1 < parts.length && this.schema.pathType(subpath) === 'virtual') {
mpath.set(path, val, this);
return this;
}
schema = this.schema.path(subpath);
if (schema == null) {
continue;
}
if (schema instanceof MixedSchema) {
// allow changes to sub paths of mixed types
mixed = true;
break;
}
}
if (schema == null) {
!o.originalModel.schema._getVirtual(o.path)) {
continue;
}
if (o.isVirtual && !o.justOne && !Array.isArray(rawIds[i])) {
if (rawIds[i] == null) {
rawIds[i] = [];
} else {
rawIds[i] = [rawIds[i]];
}
}
if (o.isVirtual && docs[i].constructor.name === 'model') {
// If virtual populate and doc is already init-ed, need to walk through
// the actual doc to set rather than setting `_doc` directly
mpath.set(o.path, rawIds[i], docs[i]);
} else {
var parts = o.path.split('.');
var cur = docs[i];
for (var j = 0; j < parts.length - 1; ++j) {
if (cur[parts[j]] == null) {
cur[parts[j]] = {};
}
cur = cur[parts[j]];
}
if (docs[i].$__) {
docs[i].populated(o.path, o.allIds[i], o.allOptions);
}
utils.setValue(o.path, rawIds[i], docs[i], setValue);
}
}
}
me.getModuleName = function (mpath) {
let m;
const stats = fs.statSync(mpath);
try {
m = require(mpath).name;
if (m) return m;
} catch (ex) {
/* not a warning yet. Eventually maybe */
}
if (stats.isDirectory()) {
try {
m = JSON.parse(fs.readFileSync(path.join(mpath, 'package.json'))).name;
if (m) return m;
} catch (ex) {
log.warn(ex, 'invalid package.json for %s', mpath);
}
}
return mpath;
};
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);
}