I have created an Account table in the PostgreSQL database using SEQUELIZE in Nodejs. I have used npx commands to create the tables.
$ npx sequelize db:create
$ npx sequelize db:migrate
By default, the table is created with double-quotes. For example, If I want to check the entries in the Account table, the sql command is as follows:
SELECT * FROM "Account";
I want to remove the double-quotes from the table name i.e.
SELECT * FROM Account;
In Sequelize Manual, I have found an option (options.quoteIdentifiers) which states that "Set to false to make table names and attributes case-insensitive on Postgres and skip double quoting of them."
When I applied this option in my code, still the Account table is created with double-quotes. I am not sure whether I commit any mistake. Please check my code below. Thanks in advance.
var sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD,
options.quoteIdentifiers = false,
{
host: dbConfig.HOST,
dialect: dbConfig.dialect,
pool: {
max: dbConfig.pool.max,
min: dbConfig.pool.min,
acquire: dbConfig.pool.acquire,
idle: dbConfig.pool.idle
}
},
);
module.exports = (sequelize, DataTypes) => {
const Account = sequelize.define('Account', {
epprojectname: DataTypes.STRING,
username: DataTypes.STRING,
projectid: DataTypes.STRING,
vendorparameters: DataTypes.STRING,
credentials: DataTypes.STRING,
author: DataTypes.STRING,
localnumber: DataTypes.STRING,
loginid: DataTypes.INTEGER,
}, {
freezeTableName: true,
},
);
You have used "=" instead of ":". You can replace the equal sign with colon and try again
const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
host: dbConfig.HOST,
dialect: dbConfig.dialect,
operatorsAliases: false,
quoteIdentifiers: false,
freezeTableName: true,
pool: {
max: dbConfig.pool.max,
min: dbConfig.pool.min,
acquire: dbConfig.pool.acquire,
idle: dbConfig.pool.idle
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments