[Question]
IDE vscode, I have been using Sequelize define model but it doesn’t show the right method when I export to controller. What an I missing?
Node 18 project-commonjs
struct
[+] dbConfig
-- config1.js
[+] Model
- model1.js
- model2.js
....
- index_model.js
[+] Controller
- model1Controller.js
model1.js
module.exports = function(sequelize, DataTypes) {
const model1 = sequelize.define('model1', {
id: {
autoIncrement: true,
type: DataTypes.INTEGER,
allowNull: false,
primaryKey: true
},
name: {
type: DataTypes.STRING(100),
allowNull: true
}
}, {
sequelize,
tableName: 'table1',
schema: 'dbo',
timestamps: false
});
return model1
};
config1.js
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(
DB_NAME,
DB_ACC,
DB_PASS,
{
host: DB_HOST,
port: 1231,
dialect: 'mssql',
dialectOptions: ...
}
);
module.exports = sequelize;
index_model.js
var {Sequelize, DataTypes , Model} = require("sequelize");
var sequelize = require("../dbConfig/config1");
var _model1 = require("./model1");
function initModels(sequelize) {
const Mode1 = _model1(sequelize,DataTypes )
}
module.exports = initModels;
module.exports.initModels = initModels;
module.exports.default = initModels;
Controller/model1Controller.js
var {Sequelize, DataTypes , Model} = require("sequelize");
var {initModels} = require("../Model/index_model");
//issue: it's not show method of Model such as: findAll, ....
initModels.model1.????
I need to show autocomplete suggestions method when calling model in controller