我正在尝试使用sequelize-cli命令插入虚拟数据
sequelize db:seed --seed seeders/20170212081140-subject_tags.js
这是我的配置文件
{
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"dialect": "sqlite",
"seederStorage": "sequelize",
"storage": "./test"
}
}
这里是我的播种文件
use strict';
module.exports = {
up: function(queryInterface, Sequelize) {
return
queryInterface.bulkUpdate('subject_tags', [
{
tag: 'agricultural-sciences',
tag_description: '',
subject_category: 'biological_&_medical_sciences',
createdAt: new Date(),
updatedAt: new Date()
}, {
tag: 'biochemistry',
tag_description: '',
subject_category: 'biological_&_medical_sciences',
createdAt: new Date(),
updatedAt: new Date()
}, {
tag: 'bioinformatics',
tag_description: '',
subject_category: 'biological_&_medical_sciences',
createdAt: new Date(),
updatedAt: new Date()
}
] , {});
},
down: function(queryInterface, Sequelize) {
return
queryInterface.bulkDelete('subject_tags', null, {});
}
};
虽然我获得了状态
Using environment "development".
== 20170212081140-subject_tags: migrating =======
== 20170212081140-subject_tags: migrated (0.053s)
我在种子文件中尝试bulkCreate
和bulkInsert
,所有这些都成功运行,但数据未插入表中
数据没有插入。我做错了吗?
答案 0 :(得分:0)
在sequlizer
语句之后它似乎与return
无关,它无法使用换行符处理空格
module.exports = {
up: function(queryInterface, Sequelize) {
//old code
//return
// queryInterface.bulkUpdate('subject_tags', [
//new code
return queryInterface.bulkUpdate('subject_tags', [
//.........
答案 1 :(得分:0)
Javascript将在悬垂的return
语句之后自动添加分号。
它没有达到bulkUpdate
代码。