Sequelize:如何从现有数据库中导入定义 [英] Sequelize: how to import definitions from an existing database

查看:83
本文介绍了Sequelize:如何从现有数据库中导入定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我正在使用现有数据库,我还是需要手写Sequelize的模型定义.

Am I required to handwrite the model definitions for Sequelize even if I'm working off of an existing database.

如果不需要,那么如何将Sequelize与现有数据库一起使用?

If it's not required, then how does one go about using Sequelize with an existing database?

我已经在Doctrine中定义了数据库的架构,所以我宁愿不必再次编写另一组模型定义.

I've already defined the database's schema in Doctrine, so I'd rather not have to write another set of model definitions again.

推荐答案

使用Sequelize,您必须在代码内部定义模型的结构.这样做,除非覆盖某些内容,否则Sequelize假定使用特定的数据库架构.简而言之:不,sequelize无法镜像数据库.

with Sequelize you have to define the structure of the model inside your code. Doing so, Sequelize assumes a specific database schema unless something is overwritten. So in short: No, sequelize cannot mirror the database.

希望有帮助:)

这篇关于Sequelize:如何从现有数据库中导入定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆