/** * Take the plain javascript object from a mongo document. * I wrote this because I could not for the life of me get class-transformer to * play along with mongo documents. * @param mongoObj Mongo database response * @returns Plain javascript object */ export default function takeMongoObject(mongoObj: T): T { const dirty = (mongoObj as Record)._doc as Record< string, unknown >; dirty.id = dirty._id.toString(); delete dirty._id; delete dirty.__v; return dirty as T; }