Node.js 错误:用户不是构造函数--带有express、sequelize和postgresSQL的节点js

Node.js 错误:用户不是构造函数--带有express、sequelize和postgresSQL的节点js,node.js,express,sequelize.js,Node.js,Express,Sequelize.js,我正在用node.js(sequalize,express)和postgresql db制作登录应用程序,同时插入数据。我正在获取错误:TypeError:用户不是构造函数 //users/user.model.js module.exports = (sequelize, type)=> { return sequelize.define('user', { id: { type: type.INTEGER, pri

我正在用node.js(sequalize,express)和postgresql db制作登录应用程序,同时插入数据。我正在获取错误:TypeError:用户不是构造函数

//users/user.model.js

module.exports = (sequelize, type)=> {
    return sequelize.define('user', {
        id: {
            type: type.INTEGER,
            primaryKey: true,
            autoIncrement: true
          },
        username:  type.STRING,
        hash: type.STRING,
        firstName: type.STRING,
        lastName: type.STRING,
    },{ freezeTableName: true })
} 
//_helper/db.js

const config = require('config.json');
const Sequelize = require('sequelize');
const UserModel = require('../users/user.model');

//const sequelize = new Sequelize('postgres://user:pass@example.com:5432/dbname');
//var sequelize = new Sequelize(config.database, config.username, config.password);
const sequelize = new Sequelize(config.connectionString1);
const User = UserModel(sequelize, Sequelize)

module.exports = {
  User
}
//users/user.service.js

const { User } = require('../_helpers/db');
sync function create(userParam) {
    const user = new User(userParam);

    // save user
    await user.save();
}

在user.service中调用save()方法后,我得到了错误。

module.exports=user
我猜。@TGrif不使用module.exports=user
const user = await User.create(userParam); no need `new` operate