sequelize/sequelize — pull request #911 by davidrivera (2013-09-16 22:55:56+00:00)
Title: sequelize import can now accept a function as the definition

Before, the import function required a path to a model definition file. This limited the ability to structure an application and define other attributes about the model (possibly outside the scope of sequelize) in the same file, e.g. model associations. Now this is possible:

sequelize.import('Posts', function(sequelize, DataTypes) {
return sequelize.define("Project", {
name: DataTypes.STRING,
description: DataTypes.TEXT
})
})

or this

// in model/posts.js
exports.definition = function(sequelize, DataTypes){ ... }
exports.name = "Post"
exports.foo = "bar"

// in app.js
var obj = require('./models/post.js')
sequelize.import(obj.name, obj.definition);

This still allows for the ability to cache imports and, for backwards compatibility, to pass a path to import:

sequelize.import(__dirname + "/path/to/models/project")