node.js - Sequelize - sequelize.sync() -
i don't understand how work istruction sequelize.sync()
. example:
into server.js file:
db.sequelize.sync().then(function() { app.listen(port); console.log("express listen on port: " + port); })
and db.js file create new database:
//create sequelize database export server.js var sequelize = require('sequelize'); var sequelize = new sequelize(undefined, undefined, undefined, { 'dialect': 'sqlite', 'storage': __dirname + '/data/dev-todo-api.sqlite' // location create new sqlite database }); var db = {}; db.todo = sequelize.import(__dirname + "/models/todo.js"); db.sequelize = sequelize; //contain settings of database db.sequelize = sequelize; module.exports = db;
and __dirname + "/models/todo.js"
have created tables/models. server.js when launch db.sequelize.sync()
, how know models must stored database? never call db.todo
( create models )
thank morris
Comments
Post a Comment