What does the force option on sequelize.sync() do?
sequelize.sync({ force: true });
Specifically, I am interested in knowing what force: false does? Will it not sync the schema with the database?
Are there any formal docs for sequelize? I could only find examples inside the docs.
The Sequelize instance method sync() is used to synchronize your Sequelize model with your database tables. The synchronization happens at the table level. When your table doesn't exist the sync() method will generate and run a CREATE TABLE statement for you.
To your question: force: true adds a DROP TABLE IF EXISTS before trying to create the table - if you force, existing tables will be overwritten. Follow this answer to receive notifications.
Typically your . sync() call will be in your server file and the var User = sequelize. define("ModelName"... will be in your models/modelName. js file.
(More or less) formal docs and API reference can be found at http://sequelize.readthedocs.org/en/latest/api/sequelize/#sync
To your question: force: true
adds a DROP TABLE IF EXISTS
before trying to create the table - if you force, existing tables will be overwritten.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With