admin管理员组文章数量:1410712
When running the mand knex migrate:make table-name
The below code is what appears in the newly created file.
exports.up = function (knex, Promise) {
})
}
exports.down = function (knex, Promise) {
}
After I created my schema I noticed that I never used the Promise argument, provided by default (my code below).
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')
}
I also had a look at other projects and realized I have never done anything with the Promise argument. Am I missing something? Or is it just provided by default and not always needed?
When running the mand knex migrate:make table-name
The below code is what appears in the newly created file.
exports.up = function (knex, Promise) {
})
}
exports.down = function (knex, Promise) {
}
After I created my schema I noticed that I never used the Promise argument, provided by default (my code below).
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')
}
I also had a look at other projects and realized I have never done anything with the Promise argument. Am I missing something? Or is it just provided by default and not always needed?
Share Improve this question asked Sep 26, 2018 at 14:04 adam.kadam.k 6323 silver badges17 bronze badges2 Answers
Reset to default 8It is not needed for anything.
It is historical argument from the time, when node didn't have builtin promises (or maybe reminder from the time when knex allowed to select promise implementation that is used).
It is just an instance of bluebird (in knex 0.15.2).
Its not required but sometimes usable. As its a instance of Bluebird, you can use some of Bluebird functions there. As for example, if you like to insert (on database seeding step), you might interested to maintain insert order. So, Bluebird.mapSeries es in.
Knex Promise Uses
本文标签: javascriptIs the Promise argument passed into Knex migrations neededStack Overflow
版权声明:本文标题:javascript - Is the Promise argument passed into Knex migrations needed? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744301751a2599615.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论