MCPcopy
hub / github.com/Pythagora-io/pythagora / stringToMongoObjectId

Function stringToMongoObjectId

src/helpers/mongodb.js:79–85  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

77}
78
79function stringToMongoObjectId(str) {
80 let idValue = str.match(objectIdAsStringRegex);
81 if (idValue && idValue[1] && ObjectId.isValid(idValue[1])) {
82 return new ObjectId(idValue[1]);
83 }
84 return str;
85}
86
87// usually, we won't pass any options because we want to get whole documents
88async function getCurrentMongoDocs(collection, query, options = {}) {

Callers 1

jsonObjToMongoFunction · 0.85

Calls 1

isValidMethod · 0.80

Tested by

no test coverage detected