gpt4 book ai didi

node.js - 在运行 sequelize 迁移时如何打印原始查询?

转载 作者:搜寻专家 更新时间:2023-10-31 22:25:54 24 4
gpt4 key购买 nike

我需要打印在迁移运行时执行的原始查询。知道如何做到这一点吗?

我使用 --migrate 选项来运行脚本。

最佳答案

You can also define a custom function for the logging part. Just pass a function. The first parameter will be the string that is logged.

您可以使用 logging , 非常简单的方法:), 添加到迁移配置 loggin: true ( DEPRECATED )

哦,对不起。我找到 source , 他们不给机会。

但你可以修复这个 self :) 暂时更改为“true”。

programmatic use :

var sequelize = require('sequelize');
var sequelize = new Sequelize('database', 'username', 'password', {
logging: console.log
})

var migrator = sequelize.getMigrator({
path: process.cwd() + '/database/migrations',
filesFilter: /\.coffee$/,
logging: console.log
})

migrator
.migrate({ method: 'down' })
.success(function() {
// The migrations have been executed!
})

关于node.js - 在运行 sequelize 迁移时如何打印原始查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21427723/

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