0
我試圖插入使用sequelize-CLI命令sequelize種子無法插入數據的SQLite
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
,所有的人都跑成功,但數據不會插入到表 的數據不會插入。我做錯了什麼嗎?
你確定你想在'up'種子使用'bulkUpdate'代替'bulkCreate'方法功能? – piotrbienias
@piotrbienias:嘗試'bulkCreate'和'bulkInsert',每件事都顯示成功遷移但數據在SQLite中不可用 –