gpt4 book ai didi

node.js - 当我没有调用它时,为什么 console.log 会显示 CREATE TABLE 语句

转载 作者:行者123 更新时间:2023-12-03 22:23:40 25 4
gpt4 key购买 nike

代码

require('dotenv/config');
const Sequelize = require('sequelize');

const connection = new Sequelize(process.env.DATABASE, process.env.USER, process.env.PASSWORD, {
host: process.env.HOST,
dialect: 'mysql',
operatorsAliases: false,

pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},

});

var Article = connection.define('article', {
title: Sequelize.STRING,
body: Sequelize.TEXT
});

connection.sync()
.then(function () {
// Article.create({
// title: 'demo title',
// body: 'Blah'
// });
Article.findById(1).then(function (article) {
console.log(article.dataValues);
});
});
// .then(function () { process.exit(); });

console.log
PS C:\code\basic-sequelize> npm start

> basic-sequelize@1.0.0 start C:\code\basic-sequelize
> node app.js

Executing (default): CREATE TABLE IF NOT EXISTS `articles` (`id` INTEGER NOT NULL auto_increment , `title` VARCHAR(255), `body` TEXT,
`createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `articles`
Executing (default): SELECT `id`, `title`, `body`, `createdAt`, `updatedAt` FROM `articles` AS `article` WHERE `article`.`id` = 1;
{ id: 1,
title: 'demo title',
body: 'Blah',
createdAt: 2018-06-12T17:07:21.000Z,
updatedAt: 2018-06-12T17:07:21.000Z }

最佳答案

这些是来自 Sequelize 的电话。如果您愿意,可以使用 logging: false, 禁用它们

const connection = new Sequelize(process.env.DATABASE, process.env.USER, process.env.PASSWORD, {
host: process.env.HOST,
dialect: 'mysql',
operatorsAliases: false,
logging: false, // <--- Disable logging
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
},

});

关于node.js - 当我没有调用它时,为什么 console.log 会显示 CREATE TABLE 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50823633/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com