·

有没有和 Sequelize 这个对比过, Sequelize 他性能咋样。

Replies
3

Sequelize 还没对比过,下载量也很高,不知道 ts 支持怎么样。

我用的方式,没有用装饰器,我是 egg + Sequelize 用的 ts,目前我觉得够用,可能我要求不高。


export default (app: Context & Application) => {
  const { model, Sequelize } = app
  // 获取数据类型
  const { INTEGER, STRING, SMALLINT, TEXT } = Sequelize

  return model.define(
    'grade', {
      id: { autoIncrement: true, type: INTEGER, allowNull: false, primaryKey: true },
      sid: { type: SMALLINT, defaultValue: 24, comment: '模型ID' },
      uid: { type: INTEGER, allowNull: false, comment: '用户ID' },
      aid: { type: INTEGER, allowNull: false, comment: '关联ID' },
      country: { type: INTEGER, allowNull: false, comment: '国家' },
      grade: { type: STRING, allowNull: false, comment: '分级' },
      content: { type: TEXT, allowNull: false, comment: '简介' }
    },
    { timestamps: false }
  ) as BaseModelStatic<GradeType>
}

自己的类型也都能提示出来。