/** * 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: any, includeMongoTimestamp?: boolean) => { // Add the mongo timestamp (if it was requested) let mongoTimestamp: (number | undefined); 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 { ...itemWithoutId, // Add mongo timestamp mongoTimestamp, }; }; export default processFindResult;