d-band/koa-orm

modal name undefind

Closed this issue · 2 comments

modal

let Game = db.define('modelName', {
    id:  { type: 'serial', key: true },
    game_name: { type:'text',size:40 },
    game_code: { type:'text',size:20 },
    game_desc: { type: 'text' },
    preview_pic: { type: 'text'},
    preview_link: { type:'text'},
    game_logo: { type:'text'},
    user_launch: { type:'integer'},
    game_type: { type:'integer'},
    defaultconfig: { type:'text'},
    lottery_platform: { type:'integer'}
  });

ctx.orm 属性打印出来

undefined: 
   { id: [Getter/Setter],
     game_name: [Getter/Setter],
     game_code: [Getter/Setter],
     game_desc: [Getter/Setter],
     preview_pic: [Getter/Setter],
     preview_link: [Getter/Setter],
     game_logo: [Getter/Setter],
     user_launch: [Getter/Setter],
     game_type: [Getter/Setter],
     defaultconfig: [Getter/Setter],
     lottery_platform: [Getter/Setter] } }

model 定义类似这样(用的 sequelize):

module.exports = function(sequelize, types) {
  var Bar = sequelize.define('Bar', {
    title: {
      type: types.STRING(50),
    },
    content: {
      type: types.STRING(50)
    },
    likes: {
      type: types.INTEGER
    }
  }, {
    tableName: 'bar'
  });
  Bar.associate = (models) => {
    Bar.belongsTo(models.Foo, {
      foreignKey: 'foo'
    });
  };
  return Bar;
};