I want to define a length of a datatype in sequelize. There is my source code :
var Profile = sequelize.define('profile', { public_id: Sequelize.STRING, label: Sequelize.STRING })
It create a table profiles with a public_id with a datatype varchar(255).
I would like to define a public_id with varchar(32).
I searched on the doc and the stack but couldn't find any answer...
How can I do that please ?
If you give the datatype as TEXT in Sequelize It will automatically convert that field to NVARCHAR(MAX ) for SQL Server database. But it is mentioned in Sequelize github repository from line 79 to 90. Show activity on this post. postgres supports Upto 1G for BOTH TEXT AND VARCHAR.
Models can be defined in two equivalent ways in Sequelize: Calling sequelize. define(modelName, attributes, options) Extending Model and calling init(attributes, options)
When you create a Sequelize model, you can add the default value for your model by adding the defaultValue option to the column(s) definition. The defaultValue option will be used by Sequelize to define default value(s) for your SQL column(s) when you create a table using Sequelize.
As it is mentioned in the documentation, use:
Sequelize.STRING(32)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With