我只想在 Sequelize 迁移中创建一行insert()。我已经看过示例,bulkInsert()但不想使用批量。我们用这个函数只创建一行:
insert(instance, tableName, values, options)
Run Code Online (Sandbox Code Playgroud)
但我不明白参数中的实例是什么?我使用它是bulkInsert因为它不询问实例参数。如果您可以在我下面编写的代码中添加插入,那就太好了。迁移库:https ://github.com/sequelize/sequelize/blob/master/lib/query-interface.js
//Code for insertion using bulkInsert
module.exports = {
up: queryInterface => {
queryInterface.describeTable("Platforms").then(attributes => {
return queryInterface.bulkInsert("Platforms", [
{
id: 6,
display_name: "Booking.com",
code: "booking.com"
}
]);
});
},
down: queryInterface => {
return queryInterface.bulkDelete("Platforms", {
id: 6
});
}
};
Run Code Online (Sandbox Code Playgroud)