import { DataType , DataTypes , ModelCtor } from 'sequelize' ; const transformers = { } ; transformers [ DataTypes . INTEGER . key ] = ( value ) => value && typeof value == 'string' ? parseInt ( value , 10 ) : value ; transformers [ DataTypes . BIGINT . key ] = ( value ) => value != null ? value . toString ( ) : null ; transformers [ DataTypes . BOOLEAN . key ] = ( value ) => value === null ? null : ( value instanceof Buffer ? ! ! value . readInt8 ( 0 ) : ! ! value ) ; export const getDeletedAtColumn = ( model ) => model . options . deletedAt || 'deletedAt' ; export const getValue = ( type , value ) => { if ( value == null ) { return null ; } const transformer = transformers [ typeof type === 'string' ? type : type . key ] ; return transformer ? transformer ( value ) : value ; } ; export const getTableName = ( model ) => { const tableName = model . getTableName ( ) ; return typeof tableName == 'string' ? tableName : `${ tableName . schema }${ tableName . delimiter }${ tableName . tableName }` ; } ;