38 lines
520 B
JavaScript
Raw Normal View History

2021-05-18 10:16:03 +02:00
'use strict';
// simple example
const dialects = {
pg: {
fields: {
string: 'varchar',
},
},
sqlite: {
fields: {
string: 'text',
},
},
};
const FIELDS = {
string: {
defaultColumnType: 'varchar',
// before write
parser: a => a,
// after read
formatter: a => a,
// before write
validator: a => a,
},
};
module.exports = {
get(type) {
if (!(type in FIELDS)) {
throw new Error(`Unknow field ${type}`);
}
return FIELDS[type];
},
};