VS Code的Intellisense没有建议Node.js中Sequelize对象的任何功能?

时间:2019-12-05 08:24:25

标签: node.js visual-studio-code sequelize.js

在遵循Sequelize的文档时,我使用sequelize对象创建了用户模型。

const Sequelize = require("sequelize");

const Model = Sequelize.Model;
const path = "mysql://user:password@localhost:3306/test_db";

const sequelize = new Sequelize(path, {
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
});

const User = sequelize.define('user', {
  firstName: {
    type: Sequelize.STRING,
    allowNull: false
  },
  lastName: {
    type: Sequelize.STRING
  }
}, {});

代码运行正常,但是问题是VS Code中的Intellisense没有建议任何功能 来自sequelize对象,如下所示:

this

这是一种错误还是我编写了错误的代码?

1 个答案:

答案 0 :(得分:1)

只需使用大括号将Sequelize导入到您的实用程序文件

const { Sequelize } = require('sequelize');