Move parseTypes function to utils

This commit is contained in:
rijkvanzanten
2020-09-17 14:50:04 -04:00
parent 8a5ddbd050
commit bed2332886
2 changed files with 10 additions and 9 deletions

View File

@@ -27,15 +27,6 @@ export const types = [
'unknown',
] as const;
export function parseTypes(type: typeof types[number]) {
if (['bigInteger', 'integer', 'float', 'decimal'].includes(type)) return 'number';
if (['string', 'text', 'uuid'].includes(type)) return 'string';
if (['boolean'].includes(type)) return 'boolean';
if (['time', 'timestamp', 'date', 'dateTime'].includes(type)) return 'string';
if (['json', 'csv'].includes(type)) return 'object';
return 'undefined';
}
export type FieldSchema = {
/** @todo import this from knex-schema-inspector when that's launched */
name: string;

View File

@@ -0,0 +1,10 @@
import { types } from '@/types';
export function getJSType(type: typeof types[number]) {
if (['bigInteger', 'integer', 'float', 'decimal'].includes(type)) return 'number';
if (['string', 'text', 'uuid'].includes(type)) return 'string';
if (['boolean'].includes(type)) return 'boolean';
if (['time', 'timestamp', 'date', 'dateTime'].includes(type)) return 'string';
if (['json', 'csv'].includes(type)) return 'object';
return 'undefined';
}