본문 바로가기
  • AI (Artificial Intelligence)
Programming/JavaScript, Node.js

[Sequelize] Data type of Model in Sequelize

by 로샤스 2021. 7. 6.

Ref. https://www.programmersought.com/article/66521561222/

See more detailsSequelize Chinese API documentation

The data type of Model in Sequelize corresponds to the data type in MySQL

Sequelize.STRING // VARCHAR(255) Type: String Maximum: 65535 characters
Sequelize.STRING(1234) // VARCHAR(1234) Type: variable length Maximum: 65535 characters
Sequelize.TEXT // TEXT Type: String Maximum: 65535 characters
Sequelize.TEXT('tiny') // TINYTEXT Type: String Maximum: 255 characters

Sequelize.INTEGER // INTEGER Type: Integer Maximum: Range (-2147483648~2147483647)
Sequelize.BIGINT // BIGINT Type: Integer Maximum: Range (+-9.22*10 to the 18th power)
Sequelize.BIGINT(11) // BIGINT(11) Type: Integer Maximum: Range (+-9.22*10 to the 18th power)

Sequelize.FLOAT // FLOAT Type: Single precision floating point type 8-bit precision (4 bytes)
Sequelize.FLOAT(11) // FLOAT(11) Type: Single precision floating point type 8-bit precision (4 bytes)
Sequelize.FLOAT(11, 12) // FLOAT(11,12) Type: Precision Floating Point 8-bit precision (4 bytes) m total number, d decimal places

Sequelize.DOUBLE // DOUBLE Type: Double-precision floating-point 16-bit precision (8 bytes) 
Sequelize.DOUBLE(11) // DOUBLE(11) Type: Double-precision floating-point 16-bit precision (8 bytes) 
Sequelize.DOUBLE(11, 12) // DOUBLE(11,12) Type: Double-precision floating-point 16-bit precision (8 bytes) m total number, d decimal places

Sequelize.DECIMAL // DECIMAL Type: Fixed point type
Sequelize.DECIMAL(10, 2) // DECIMAL(10,2) Type: Fixed point type Parameter m<65 is the total number, d<30 and d<m is the decimal place

Sequelize.DATE // DATETIME Type: Datetime Type Example: '2009-05-12 02:31:44'
Sequelize.DATE(6)                     // DATETIME(6)    
Sequelize.DATEONLY                    // DATE without time.
Sequelize.BOOLEAN // TINYINT(1) Type: Integer Range (-128~127)

Sequelize.ENUM('value 1', 'value 2') // ENUM type: enumeration

Sequelize.BLOB // BLOB type: binary data
Sequelize.BLOB('tiny') // TINYBLOB type: binary data

댓글