UNPKG

@r1tsu/payload

Version:

21 lines (20 loc) 530 B
const internalFields = [ '__v' ]; const sanitizeInternalFields = (incomingDoc)=>Object.entries(incomingDoc).reduce((newDoc, [key, val])=>{ if (key === '_id') { return { ...newDoc, id: val }; } if (internalFields.indexOf(key) > -1) { return newDoc; } return { ...newDoc, [key]: val }; }, {}); export default sanitizeInternalFields; //# sourceMappingURL=sanitizeInternalFields.js.map