Skip to content

Instantly share code, notes, and snippets.

@evantahler
Created November 15, 2015 02:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evantahler/801a07085f230fa7f55d to your computer and use it in GitHub Desktop.
Save evantahler/801a07085f230fa7f55d to your computer and use it in GitHub Desktop.
Actionhero + MySQL
config.mySQL = {
"database" : "v3_development",
"dialect" : "mysql",
"port" : 3306,
"pool" : {
"maxConnections" : 20,
"maxIdleTime" : 30000
},
"replication" : {
"write": {
"host" : "127.0.0.1",
"username" : "root",
"password" : "",
"pool" : {}
},
"read": [
{
"host" : "127.0.0.1",
"username" : "root",
"password" : "",
"pool" : {}
}
]
}
}
var Sequelize = require("sequelize");
var SequelizeFixtures = require('sequelize-fixtures');
module.exports = {
start: function(api, next){
api.mySQL.sequelize = new Sequelize(api.config.mySQL.database, null, null, api.config.mySQL);
api.models = {
user: api.mySQL.sequelize.import(__dirname + "/../models/user.js"),
slug: api.mySQL.sequelize.import(__dirname + "/../models/slug.js"),
// ...
}
next();
},
stop: {
api.mySQL.sequelize.disconnect(function(){
next();
});
},
}
module.exports = function(sequelize, DataTypes) {
return sequelize.define("user", {
email: DataTypes.STRING,
first_name: DataTypes.STRING,
last_name: DataTypes.STRING,
password_hash: DataTypes.STRING,
password_salt: DataTypes.STRING,
admin: DataTypes.BOOLEAN,
}, {
timestamps: true
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment