typeormgen
Advanced tools
Comparing version 0.10.0 to 0.11.0
29
index.js
const Big = require('big.js'); | ||
const moment = require('moment'); | ||
const timeRegex = /^([0-1]\d|2[0-3]):([0-5]\d):([0-5]\d)$/g; | ||
@@ -54,6 +55,32 @@ const bigTransformer = { | ||
const timeTransformer = { | ||
// called on value when fetching from database | ||
from: function (value) { | ||
if (value && !moment.isMoment(value)) { | ||
if (value.match(timeRegex)) { | ||
return moment(value, 'HH:mm:ss'); | ||
} else { | ||
return moment(value); | ||
} | ||
} | ||
return value; | ||
}, | ||
// called on value before persisting to database | ||
to: function (value) { | ||
if (value && !moment.isMoment(value)) { | ||
if (value.match(timeRegex)) { | ||
return moment(value, 'HH:mm:ss').format('HH:mm:ss'); | ||
} else { | ||
return moment(value).format('HH:mm:ss'); | ||
} | ||
} | ||
return value.format('HH:mm:ss'); | ||
} | ||
}; | ||
module.exports = { | ||
bigTransformer, | ||
booleanTransformer, | ||
momentTransformer | ||
momentTransformer, | ||
timeTransformer | ||
}; |
{ | ||
"name": "typeormgen", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Generate typeorm models from your database tables", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23200
615
1