dce-mango
Version:
Harvard DCE's Non-relational DB Wrapper.
29 lines • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Process the result of a find query to match the DocumentType, by removing `_id` and adding timestamps.
* @author Gabe Abrams
* @param item the item to be processed
* @param includeMongoTimestamp whether to include a timestamp or not
* @returns the processed item, after removing _id
*/
const processFindResult = (item, includeMongoTimestamp) => {
// Add the mongo timestamp (if it was requested)
let mongoTimestamp;
if (includeMongoTimestamp) {
mongoTimestamp = (1000
* Number.parseInt(
// eslint-disable-next-line no-underscore-dangle
item._id.toString().substring(0, 8), 16));
}
// Delete internal id
const itemWithoutId = item;
// eslint-disable-next-line no-underscore-dangle
delete itemWithoutId._id;
// Duplicate as object
return Object.assign(Object.assign({}, itemWithoutId), {
// Add mongo timestamp
mongoTimestamp });
};
exports.default = processFindResult;
//# sourceMappingURL=processFindResult.js.map