简体   繁体   English

在 JSON 格式的 MySQL 查询中使用 JavaScript 创建一个表

[英]Create a TABLE in MySQL query in JSON format with JavaScript

is there any possibility to create a new Table with JSON Format to MySQL.是否有可能使用 JSON 格式创建一个新表,格式为 MySQL。 I have the following test JSON file and want to create a new table out of it我有以下测试 JSON 文件并想从中创建一个新表

[
    {
        "name": "arbeitszeitmodelle",
        "columns": {
            "test": "SMALLINT",
            "test2": "STRING"
        }
    }
]

In the following line is the code I want to create the table.以下行是我要创建表的代码。 Is it there possible to create the columns with JSON是否可以使用 JSON 创建列

con.query("CREATE TABLE " + element.name + " /*What is to fill here?*/")

I thank you all:D谢谢大家:D

It is always best to use an ORM to do all your database queries and CRUD operations rather than building your own raw query.最好使用 ORM 来执行所有数据库查询和 CRUD 操作,而不是构建自己的原始查询。

For Node.JS one of the most popular ORM's is Sequelize .对于 Node.JS,最流行的 ORM 之一是Sequelize

You can read the documentation here for more details.您可以在此处阅读文档以获取更多详细信息。

Hope this helps you!希望这对你有帮助!

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

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