简体   繁体   English

通过 node js 索引文件或通过 node 命令运行所有 sequelize 迁移代码

[英]Run all the sequelize migration code through node js index file or through node command

I am very new to this ORM concept I know for mongoDB there is mongoose but I am working with MYSQL so I came to know about sequelize and sequqlize-migration but it seems very hard to me as compare to mongoose I am very new to this ORM concept I know for mongoDB there is mongoose but I am working with MYSQL so I came to know about sequelize and sequqlize-migration but it seems very hard to me as compare to mongoose

My question is there any way to simplify the thing like I have my index.js file in and I want to run do all the action using this file so how can I do this, right now I am using this command to update the things我的问题是有什么方法可以简化事情,比如我有我的index.js文件,我想使用这个文件运行所有操作,所以我该怎么做,现在我正在使用这个命令来更新这些东西

npx sequelize-cli db:migrate

I want to run my program as我想运行我的程序

node index.js

and want the things to be done, right now there config, migration, models directory how to sum up the process into one file.并且想要做的事情,现在有config, migration, models目录如何将过程总结成一个文件。

Use scripts in package.json

  "scripts": {
    "start": "npx sequelize-cli db:migrate && node server.js",
  },

It will first run npx sequelize-cli thing and would wait for it to finish before running node server.js

Hope it answers your question

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM