@brontosaurus/db
Version:
:ocean: Schema for brontosaurus
32 lines (31 loc) • 963 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateObjectIDList = exports.parseObjectIDList = void 0;
const bson_1 = require("bson");
const parseObjectIDList = (list) => {
const result = [];
for (const each of list) {
if (bson_1.ObjectID.isValid(each)) {
if (typeof each === 'string') {
result.push(new bson_1.ObjectID(each));
}
else if (typeof each === 'number') {
result.push(new bson_1.ObjectID(each));
}
else {
result.push(each);
}
}
}
return result;
};
exports.parseObjectIDList = parseObjectIDList;
const validateObjectIDList = (list) => {
for (const each of list) {
if (!bson_1.ObjectID.isValid(each)) {
return false;
}
}
return true;
};
exports.validateObjectIDList = validateObjectIDList;