popurelate
Version:
Easily populate and filter documents using data from related collections.
26 lines (25 loc) • 820 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSubPathOf = exports.normalizeQueryPath = exports.joinQueryPath = void 0;
const joinQueryPath = (parentPrefix, path) => {
if (!parentPrefix)
return path;
return parentPrefix + "." + path;
};
exports.joinQueryPath = joinQueryPath;
const normalizeQueryPath = (path) => {
return path.replace(/\[\]/g, "");
};
exports.normalizeQueryPath = normalizeQueryPath;
function isSubPathOf(subst, string) {
if (string === subst || subst === "")
return true;
const indexOf = string.indexOf(subst);
if (indexOf !== 0)
return false;
const nextChar = string[subst.length];
if (nextChar === ".")
return true;
return false;
}
exports.isSubPathOf = isSubPathOf;