运行命令时 knex migrate:make table-name
下面的代码出现在新创建的文件中。
exports.up = function (knex, Promise) {
})
}
exports.down = function (knex, Promise) {
}
在创建模式后,我注意到我从未使用过默认提供的 Promise 参数(我的代码如下)。
exports.up = function (knex, Promise) {
return knex.schema.createTable('Skills', (table) => {
table.increments('id').primary()
table.string('skill')
table.string('description')
table.integer('rating')
})
}
exports.down = function (knex, Promise) {
return knex.schema.dropTable('Skills')
}
我还查看了其他项目并意识到我从未对 Promise 参数做过任何事情。我错过了什么吗?或者它只是默认提供,并不总是需要?
最佳答案
什么都不需要。
这是当时的历史论据,当时 Node 没有内置 promise (或者可能是 knex 允许选择使用的 promise 实现时的提醒)。
它只是 bluebird 的一个实例(在 knex 0.15.2 中)。
关于javascript - 是否需要将 Promise 参数传递给 Knex 迁移?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52519636/