本文介绍了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中创建了一些模式,该如何同步
If I've already created some schemas in Postgres, how I could sync them with Sequelize?
推荐答案您可以使用 model.schema ,例如:
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模式
发布评论