UNPKG

cosmos-db-repositories

Version:
20 lines (19 loc) 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const uuid_1 = require("uuid"); const cleanUp = (entity) => { return Object.assign(Object.assign({}, entity), { _rid: undefined, _self: undefined, _etag: undefined, _attachments: undefined, _ts: undefined }); }; const create = (data, supplier) => { const meta = (typeof supplier === 'function') ? supplier(data) : (supplier || {}); return Object.assign(Object.assign(Object.assign({}, data), { createdDate: new Date(), markAsDeleted: false, id: (0, uuid_1.v4)() }), meta); }; const update = (data, supplier) => { const meta = (typeof supplier === 'function') ? supplier(data) : (supplier || {}); return Object.assign(Object.assign(Object.assign({}, data), { updatedDate: new Date() }), meta); }; exports.default = { cleanUp, create, update };