当前位置:网站首页>Serialize data type
Serialize data type
2022-07-25 23:17:00 【Intern Sen】
Sequelize There are many built-in data types , To access built-in data types , You have to import DataTypes:
const {
DataTypes } = require("sequelize"); // Import built-in data types
character string
DataTypes.STRING // VARCHAR(255)
DataTypes.STRING(1234) // VARCHAR(1234)
DataTypes.STRING.BINARY // VARCHAR BINARY
DataTypes.TEXT // TEXT
DataTypes.TEXT('tiny') // TINYTEXT
DataTypes.CITEXT // CITEXT only PostgreSQL and SQLite.
DataTypes.TSVECTOR // TSVECTOR only PostgreSQL.
Boolean
DataTypes.BOOLEAN // TINYINT(1)
Numbers
DataTypes.INTEGER // INTEGER
DataTypes.BIGINT // BIGINT
DataTypes.BIGINT(11) // BIGINT(11)
DataTypes.FLOAT // FLOAT
DataTypes.FLOAT(11) // FLOAT(11)
DataTypes.FLOAT(11, 10) // FLOAT(11,10)
DataTypes.REAL // REAL only PostgreSQL.
DataTypes.REAL(11) // REAL(11) only PostgreSQL.
DataTypes.REAL(11, 12) // REAL(11,12) only PostgreSQL.
DataTypes.DOUBLE // DOUBLE
DataTypes.DOUBLE(11) // DOUBLE(11)
DataTypes.DOUBLE(11, 10) // DOUBLE(11,10)
DataTypes.DECIMAL // DECIMAL
DataTypes.DECIMAL(10, 2) // DECIMAL(10,2)```
date
DataTypes.DATE // DATETIME Apply to mysql / sqlite, With time zone TIMESTAMP Apply to postgres
DataTypes.DATE(6) // DATETIME(6) Apply to mysql 5.6.4+. Support 6 Decimal second of precision
DataTypes.DATEONLY // Without time DATE
UUID
about UUID, Use DataTypes.UUID.
about PostgreSQL and SQLite, It would be UUID data type ;
about MySQL, It becomes CHAR(36).
Sequelize These fields can be automatically generated UUID, Just use DataTypes.UUIDV1 or DataTypes.UUIDV4 As the default value :
{
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4 // or DataTypes.UUIDV1
}
Code examples
const qs_info = sequelize.define('qs_info', {
SAP_DOC: {
type: DataTypes.STRING, allowNull: false },
CEDL_ID: {
type: DataTypes.STRING, },
YarnColor: {
type: DataTypes.STRING, },
Collaudo: {
type: DataTypes.STRING, },
DescrSapYarn: {
type: DataTypes.STRING, },
SapYarn: {
type: DataTypes.STRING, },
XYZ: {
type: DataTypes.STRING, },
DTEX: {
type: DataTypes.FLOAT, },
FILAMENTS: {
type: DataTypes.INTEGER, },
COLOR_FAMILY: {
type: DataTypes.STRING, },
POType: {
type: DataTypes.BOOLEAN, },
Antistatic: {
type: DataTypes.BOOLEAN, },
ASType: {
type: DataTypes.STRING, },
creator: {
type: DataTypes.STRING, },
createdTime: {
type: DataTypes.DATE, defaultValue: DataTypes.NOW },
company: {
type: DataTypes.STRING }
}, {
timestamps: false,
});
// qs_info.sync({ force: true }).then(() => { });
module.exports = qs_info;
边栏推荐
- 5 ROS simulation modeling (3-rviz+gazebo+ control simulation robot)
- 如何获取广告服务流量变现数据,助力广告效果分析?
- The fifth article in the series of radar Fundamentals: the function of radar modulation style
- Explain in detail the addition (+) operation in JS, basic data type addition, reference data type addition, and the underlying operation rules, [] + {}, {} + []
- The difference between MySQL clustered index and non clustered index
- How does Navicat modify the language (Chinese or English)?
- 类和对象(3)
- EasyExcel实用技巧
- 赋能合作伙伴,亚马逊云科技如何落地“扶上马,送一程”?
- Wamp MySQL empty password
猜你喜欢

File contains vulnerability

Enabling partners, how can Amazon cloud technology "get on the horse and get a ride"?

5 ROS simulation modeling (3-rviz+gazebo+ control simulation robot)

serialization and deserialization

Tips for using (1)

驱动板网线直连电脑共享网络配置

Enterprise level inventory management system of code audit

向下扎根,向上生长,探寻华为云AI的“根”力量

POI特效 市场调研

WordPress removes the website publishing time
随机推荐
Ma Tiji Wanmin hall Chef
电商RPA,大促轻松上阵的法宝
Unity 使用宏
Very simple vsplayaudio online music player plug-in
2021-09-30
[PTA] 7-24 minimum fraction (15 points)
Analysis of direction finding error of multi baseline interferometer system
QT add mouse event to control
JS regular expression matches IP address (IP address regular expression verification)
PHP binary array is sorted by a field in it
Node基础
[opencv] edge detection [API and source code implementation]
Zero crossing position search of discrete data (array)
Mongodb的特点、与MySQL的差别、以及应用场景
ZCMU--5015: 完成任务
PyTorch的数据输入格式要求及转换
赋能合作伙伴,亚马逊云科技如何落地“扶上马,送一程”?
IPFs of Internet Protocol
栈与Stack类
Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download