sequelize#TextLength TypeScript Examples
The following examples show how to use
sequelize#TextLength.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SequelizeTypeInterpreter.ts From aloxide with Apache License 2.0 | 5 votes |
interpret(input: Field): DataType {
let type: DataType;
switch (input.type) {
case FieldTypeEnum.uint16_t:
type = DataTypes.SMALLINT;
break;
case FieldTypeEnum.uint32_t:
type = DataTypes.INTEGER;
break;
case FieldTypeEnum.uint64_t:
type = DataTypes.BIGINT;
break;
case FieldTypeEnum.number:
case FieldTypeEnum.double:
type = DataTypes.DOUBLE;
break;
case FieldTypeEnum.bool:
type = DataTypes.BOOLEAN;
break;
case FieldTypeEnum.account:
type = DataTypes.STRING;
break;
case FieldTypeEnum.string:
if (input.meta) {
if (input.meta.length) {
type = DataTypes.STRING(input.meta.length);
} else if (input.meta.type) {
type = DataTypes.TEXT({
length: input.meta.type as TextLength,
});
}
}
if (!type) {
type = DataTypes.TEXT;
}
break;
default:
throw new Error(`unknow type ${input}`);
}
return type;
}