Sequelize – sequelize.sync()

我不明白它是如何工作的istruction sequelize.sync() 。 这是一个例子:

进入我的server.js文件:

 db.sequelize.sync().then(function() { app.listen(PORT); console.log("Express listen on port: " + PORT); }) 

并进入我的db.js文件来创build一个新的数据库:

 //create a sequelize database for export it into server.js var Sequelize = require('sequelize'); var sequelize = new Sequelize(undefined, undefined, undefined, { 'dialect': 'sqlite', 'storage': __dirname + '/data/dev-todo-api.sqlite' // location where you create a new sqlite database }); var db = {}; db.todo = sequelize.import(__dirname + "/models/todo.js"); db.sequelize = sequelize; //contain a settings of database db.Sequelize = Sequelize; module.exports = db; 

并进入__dirname + "/models/todo.js" /models/ __dirname + "/models/todo.js"我已经创build了我的表/模型。 当我启动db.sequelize.sync() ,进入server.js,怎么知道我的模型必须存储到数据库中? 我从来没有调用db.todo (仅用于创build模型)

非常感谢Morris

       

网上收集的解决方案 "Sequelize – sequelize.sync()"