Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can you support egg-typescript? #32

Open
jtyjty99999 opened this issue Jul 14, 2020 · 0 comments
Open

can you support egg-typescript? #32

jtyjty99999 opened this issue Jul 14, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@jtyjty99999
Copy link

jtyjty99999 commented Jul 14, 2020

like code below

import { Application } from 'egg';

export default (app: Application) => {
  const DataTypes = app.Sequelize;
  const sequelize = app.model;
  const attributes = {
    id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: null,
      field: 'id',
      unique: 'uk_id',
    },
    name: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: 'user name',
      field: 'name',
    },
    email: {
      type: DataTypes.STRING(32),
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: 'user email',
      field: 'name',
    },
    createdAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: 'created time',
      field: 'created_at',
    },
    updatedAt: {
      type: DataTypes.DATE,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: 'update time',
      field: 'updated_at',
    },
  };
  const options = {
    tableName: 'user',
    comment: 'user table',
    indexes: [{
      name: 'uk_name_email',
      unique: true,
      fields: [
        'name',
        'email',
      ],
    }]
  };

  const UserModel = sequelize.define('userModel', attributes, options);
  return class extends UserModel {
    static associate() {
    }
  };
};
@jtyjty99999 jtyjty99999 changed the title can you support egg-ts? can you support egg-typescript? Jul 14, 2020
@nodejh nodejh added the enhancement New feature or request label Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants