UNPKG

gypsum

Version:

Simple and easy lightweight typescript server side framework on Node.js.

24 lines 872 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const MongoDB = require("mongodb"); function toObjectID(query) { if (!query || !query._id || query._id instanceof MongoDB.ObjectID) return query; if (typeof query._id === 'string') { query._id = new MongoDB.ObjectID(query._id); return query; } for (let prop in query._id) { if (Array.isArray(query._id[prop])) query._id[prop] = query._id[prop].map((id) => { if (typeof id === "string") return new MongoDB.ObjectID(id); return id; }); else if (typeof query._id[prop] === 'string') query._id[prop] = new MongoDB.ObjectID(query._id[prop]); } return query; } exports.toObjectID = toObjectID; //# sourceMappingURL=util.js.map