I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names
While the accepted answer is correct, you can do this once for all tables rather than having to do it separately for each one. You simply pass in a similar options object into the Sequelize constructor, like so:
var Sequelize = require('sequelize');
//database wide options
var opts = {
define: {
//prevent sequelize from pluralizing table names
freezeTableName: true
}
}
var sequelize = new Sequelize('mysql://root:123abc@localhost:3306/mydatabase', opts)
Now when you define your entities, you don't have to specify freezeTableName: true:
var Project = sequelize.define('Project', {
title: Sequelize.STRING,
description: Sequelize.TEXT
})