d-band/koa-orm

Model

Closed this issue · 1 comments

How do you declare a model with this ORM?

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;
};