Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 PostgreSQL 和 Sequilize 构建一个 nodejs API。我的客户给了我一个从 dbdiagram.io 导出的 .sql 文件。
是否可以基于 .sql 文件生成我所有的模型?
还是我必须手动完成所有操作?
Sequelize-auto可以自动创建模型文件(它是一个 npm 包)。
您需要使用 SQL 文件创建一个数据库,然后使用sequelize-auto.
sequelize-auto.
它通过命令行自动为 SequelizeJS 生成模型。
安装:
npm install -g sequelize-auto
使用命令行:
sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres
Sequelize-auto npm 链接