UNPKG

@env0/dynamo-easy

Version:

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.

22 lines 650 B
function dateFromDb(attributeValue) { if (attributeValue.N) { return new Date(parseInt(attributeValue.N, 10)); } else { throw new Error('there is no N(umber) value defiend on given attribute value'); } } function dateToDb(modelValue) { // noinspection SuspiciousInstanceOfGuard if (modelValue && modelValue instanceof Date) { return { N: `${modelValue.getTime()}` }; } else { throw new Error('the given model value must be an instance of Date'); } } export const dateToNumberMapper = { fromDb: dateFromDb, toDb: dateToDb, }; //# sourceMappingURL=date-to-number.mapper.js.map