0

I use actionhero + sequelize plus mysql. When I do this

var sequelize = new Sequelize("MJN", "testUser", "testPasss", {
            "host": "192.168.123.321",
            "dialect": "mysql",
            "port": 3306,
            "pool": {
                "maxConnections": 20,
                "maxIdleTime": 30000
            }
});

var MJNCustomer = sequelize.import(__dirname + "/../models/MJNCustomer.js");

I do console.log(MJNCustomer.tableName);, and it return MJNCustomers instead of MJNCustomer.

Here is models/MJNCustomer.js

module.exports = function(sequelize, DataTypes) {
return sequelize.define('MJNCustomer', {
    customerId:         DataTypes.STRING,
    fname:              DataTypes.STRING,
    lname:              DataTypes.STRING,
    address1:           DataTypes.STRING,
    address2:           DataTypes.STRING,
    city:               DataTypes.STRING,
    phoneNumber:        DataTypes.STRING
});

}

what did I do wrong here?

Thang Pham
  • 38,125
  • 75
  • 201
  • 285

1 Answers1

0

You can now use ah-sequelize-plugin and then just access your models using api.models object.

Models are loaded into api.models, so the example above would be api.models.Project. These module.exports allow for a third optional parameter "api" which is the ActionHero API object. This can be used to access configs and initializer functions, among other things.

Muhamed Krlić
  • 1,462
  • 2
  • 16
  • 25