本文介绍了Node.js:在 Sequelize 中定义 Postgres 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
官方文档没有明确解释如何为数据库定义模式通过他们自己.我假设 Sequelize 与 MySql 比 Postgres 更相关(其中模式是强制性的).
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 schemas are mandatory).
如果我已经在 Postgres 中创建了一些模式,如何将它们与 Sequelize 同步?
If I've already created some schemas in Postgres, how I could sync them with Sequelize?
推荐答案您可以使用 model.schema 设置带有模式的模型,例如:
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");更多推荐
Node.js:在 Sequelize 中定义 Postgres 模式
发布评论