mirror of
https://github.com/directus/directus.git
synced 2026-01-24 23:58:02 -05:00
Move parseTypes function to utils
This commit is contained in:
@@ -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;
|
||||
|
||||
10
app/src/utils/get-js-type.ts
Normal file
10
app/src/utils/get-js-type.ts
Normal 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';
|
||||
}
|
||||
Reference in New Issue
Block a user