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

Feature request: option to create class-based models with model:generate #678

Closed
HugoDF opened this issue Jul 31, 2018 · 0 comments · Fixed by #909
Closed

Feature request: option to create class-based models with model:generate #678

HugoDF opened this issue Jul 31, 2018 · 0 comments · Fixed by #909

Comments

@HugoDF
Copy link

HugoDF commented Jul 31, 2018

What you are doing?

I'm generating models using:

npx sequelize model:generate --name MyModel --attributes myField:string

What do you expect to happen?

I'm using models using ES6 class syntax which look like the following:

'use strict';
const { Model } = require("sequelize");
class MyModel extends Model {
  static init(sequelize, DataTypes) {
    return super.init(
      {
        myField: DataTypes.STRING
      },
      { sequelize }
    );
  }
  static associate (models) {
    // associations can be defined here
  }
}

What is actually happening?

'use strict';
module.exports = (sequelize, DataTypes) => {
  var MyModel = sequelize.define('MyModel', {
    myField: DataTypes.STRING
  }, {});
  MyModel.associate = function(models) {
    // associations can be defined here
  };
  return MyModel;
};

This isn't a bug as much as a feature request, I would be happy to contribute a an ES6 class model template and to have a CLI flag to toggle to it if this is something you guys are keen to have.

Dialect: postgres
Sequelize CLI version: 4.0.0
Sequelize version: 4.37.5

@HugoDF HugoDF changed the title Feature request: create class-based models with model:generate Option to create class-based models with model:generate Jul 31, 2018
@HugoDF HugoDF changed the title Option to create class-based models with model:generate Feature request: option to create class-based models with model:generate Jul 31, 2018
codetriage-readme-bot pushed a commit to codetriage-readme-bot/cli that referenced this issue Jun 5, 2019
…acts

Add missing teardown for test artifacts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant