ah-sequelize-plugin
Advanced tools
Comparing version 0.0.3 to 0.0.4
exports.default = { | ||
sequelize: function(api){ | ||
return { | ||
"database" : "DEVELOPMENT_DB", | ||
"database" : "DEVELOPMNET_DB", | ||
"dialect" : "mysql", | ||
@@ -6,0 +6,0 @@ "port" : 3306, |
@@ -11,2 +11,19 @@ var path = require('path'); | ||
_start: function(api, next){ | ||
next(); | ||
}, | ||
_teardown: function(api, next){ | ||
next(); | ||
}, | ||
migrate: function(next){ | ||
var migrator = api.sequelize.sequelize.getMigrator({ | ||
path: api.project_root + '/migrations', | ||
}); | ||
migrator.migrate.success(function() { | ||
if(typeof next === 'function'){ next(); } | ||
}) | ||
}, | ||
connect: function(next){ | ||
var self = this; | ||
@@ -30,3 +47,2 @@ | ||
var SequelizeFixtures = require('sequelize-fixtures'); | ||
SequelizeFixtures.loadFile(api.project_root + '/test/fixtures/*.json', api.models, function(){ | ||
@@ -40,17 +56,4 @@ SequelizeFixtures.loadFile(api.project_root + '/test/fixtures/*.yml', api.models, function(){ | ||
} | ||
}, | ||
} | ||
_teardown: function(api, next){ | ||
next(); | ||
}, | ||
migrate: function(next){ | ||
var migrator = api.sequelize.sequelize.getMigrator({ | ||
path: api.project_root + '/migrations', | ||
}); | ||
migrator.migrate.success(function() { | ||
if(typeof next === 'function'){ next(); } | ||
}) | ||
}, | ||
test: function(next){ | ||
@@ -69,3 +72,8 @@ // ensure the connection with a test | ||
next(); | ||
api.sequelize.connect(function(){ | ||
// api.sequelize.migrate(function(){ | ||
next(); | ||
// }); | ||
}); | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "I use sequelize in actionhero as an ORM", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"homepage": "http://actionherojs.com", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -7,2 +7,3 @@ # ah-sequelize-plugin | ||
- install this plugin: `npm install ah-sequelize-plugin --save` | ||
- be sure to enable the pluggin within actionhero (`config/api.js`) | ||
@@ -52,8 +53,14 @@ - you will need to add the sequelize package (`npm install sequelize --save`) to your package.json | ||
api.models.user.hasMany(api.models.posts); | ||
api.models.posts.hasMany(api.models.comments); | ||
api.associations = {}; | ||
api.models.comments.belongsTo(api.models.posts); | ||
api.models.posts.belongsTo(api.models.user); | ||
api.associations._start = function(api, next){ | ||
api.models.user.hasMany(api.models.posts); | ||
api.models.posts.hasMany(api.models.comments); | ||
api.models.comments.belongsTo(api.models.posts); | ||
api.models.posts.belongsTo(api.models.user); | ||
next(); | ||
}; | ||
next(); | ||
@@ -60,0 +67,0 @@ } |
6620
124
70