sequelize / sequelize-auto

Automatically generate bare sequelize models from your database.
2.9k stars 527 forks source link

Simplification proposal for the output formats. #653

Open adminy opened 1 year ago

adminy commented 1 year ago

Suppose instead of es5, es6, esm, ts types, it outputted this json structure:

  [
    {
      "tableName": "models"
    },
    {
      "id": {
        "type": "DataTypes.INTEGER(11)",
        "allowNull": false,
        "primaryKey": true,
        "comment": "null",
        "autoIncrement": true
      },
      "dbname": {
        "type": "DataTypes.STRING(45)",
        "allowNull": false,
        "autoIncrement": false,
        "comment": "null"
      },
      "tablename": {
        "type": "DataTypes.STRING(45)",
        "allowNull": false,
        "autoIncrement": false,
        "comment": "null"
      },
      "weekday": {
        "type": "DataTypes.ENUM(\"Sun\",\"Mon\",\"Tues\",\"Wed\",\"Thur\",\"Fri\",\"Sat\")",
        "allowNull": false,
        "autoIncrement": false,
        "comment": "null"
      },
      "createdDate": {
        "type": "DataTypes.DATE",
        "allowNull": true,
        "defaultValue": "CURRENT_TIMESTAMP",
        "autoIncrement": false,
        "comment": "null"
      }
    }
  ]

Which makes it easy for you to simply Sequelize.import it.

It is a more convenient and useful from any js version to use the json format rather than version specific javascript code.

siniradam commented 5 months ago

This is a good idea. I forked sequelize-auto I'd like to try this.