UNPKG

@warp-works/warpjs-mongo-persistence

Version:

Mongo implementation for persistence layer of WarpWorks

23 lines (17 loc) 403 B
const _ = require('lodash'); const ObjectID = require('mongodb').ObjectID; module.exports = (doc) => { if (_.isString(doc)) { doc = { id: doc }; } const converted = _.omit(doc, 'id'); if (doc.id) { converted._id = ObjectID(doc.id); } if (doc.parentID) { converted.parentID = ObjectID(doc.parentID); } return converted; };