Node.js: Defining Postgres Schemas in Sequelize

前端 未结 1 1900
抹茶落季
抹茶落季 2021-02-11 06:28

The Official Documentation doesn\'t explains clearly how define schemas for database by themselves. I\'m assuming that Sequelize is more related to MySql than Postgres (where sc

1条回答
  •  伪装坚强ぢ
    2021-02-11 07:13

    You can set the model with the schema using model.schema, something like:

    var City = sequelize.define('City', {
        id: {
            type: sequelize.Sequelize.INTEGER,
            primaryKey: true,
            autoIncrement: true,
            field: 'id'
        },
        name: {
            type: sequelize.Sequelize.STRING,
            field: 'name'   
        }
      }, {
        timestamps: false,
        tableName: 'cities'
        });
    City.schema("public");
    

    0 讨论(0)
提交回复
热议问题