Customizing Sequelize date format with Sequelize.fn() Thesequelize.fn()method is used to call a native database function to modify the way your query worksFor example, you can call the UPPER() function of MySQL and apply it to a column that you have as follows: The sequelize.fn() method is used to call a native database function to modify the way… Continue reading How to format the date for date types values using Sequelize
Tag: sequalize
How to execute/ use a raw query with Sequelize
When using Sequelize to manipulate your database from a JavaScript application, there might be cases where you want to just execute a raw SQL query instead of using Sequelize Model methods. By default the function will return two arguments – a results array, and an object containing metadata (such as amount of affected rows, etc).… Continue reading How to execute/ use a raw query with Sequelize
How to add primary key constraint in Sequelize
Sequelize provides the primaryKey option that you can add to your Sequelize model attributes. The primaryKey option allows you to assign the PRIMARY KEY constraint to your model columns. When you sync() the above Sequelize model, the user_id column will be created as the PRIMARY KEY column of the Users table in your database. You… Continue reading How to add primary key constraint in Sequelize