sequelize.sync() 如何工作,特别是 force 选项? [英] How does sequelize.sync() work, specifically the force option?

查看:77
本文介绍了sequelize.sync() 如何工作,特别是 force 选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sequelize.sync() 上的 force 选项有什么作用?

What does the force option on sequelize.sync() do?

sequelize.sync({
    force: true
});

具体来说,我很想知道 force: false 是什么?它不会将架构与数据库同步吗?

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.

推荐答案

(或多或少)正式文档和 API 参考可以在 http://sequelize.readthedocs.org/en/latest/api/sequelize/#sync

(More or less) formal docs and API reference can be found at http://sequelize.readthedocs.org/en/latest/api/sequelize/#sync

对于您的问题:force: true 在尝试创建表之前添加 DROP TABLE IF EXISTS - 如果您强制,现有表将被覆盖.

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.

这篇关于sequelize.sync() 如何工作,特别是 force 选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆