Model
Closed this issue · 1 comments
Deleted user commented
How do you declare a model with this ORM?
helloyou2012 commented
https://github.com/d-band/koa-orm/tree/master/test/fixtures/orm_test
// foo.js
module.exports = function(sequelize, types) {
return sequelize.define('Foo', {
name: {
type: types.STRING(50),
},
pass: {
type: types.STRING(50)
}
}, {
tableName: 'foo'
});
};
// bar.js
module.exports = function(sequelize, types) {
const Bar = sequelize.define('Bar', {
title: {
type: types.STRING(50),
},
content: {
type: types.STRING(50)
}
}, {
tableName: 'bar'
});
Bar.associate = (models) => {
Bar.belongsTo(models.Foo, {
foreignKey: 'foo'
});
};
return Bar;
};