2017-02-19 21 views
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) 

我在種子文件試圖bulkCreatebulkInsert,所有的人都跑成功,但數據不會插入到表 的數據不會插入。我做錯了什麼嗎?

+0

你確定你想在'up'種子使用'bulkUpdate'代替'bulkCreate'方法功能? – piotrbienias

+0

@piotrbienias:嘗試'bulkCreate'和'bulkInsert',每件事都顯示成功遷移但數據在SQLite中不可用 –

回答

0

這似乎是問題與sequlizer,後return聲明它無法與換行符處理空間

module.exports = { 
    up: function(queryInterface, Sequelize) { 
    //old code 
    //return 
    // queryInterface.bulkUpdate('subject_tags', [ 

    //new code 
    return queryInterface.bulkUpdate('subject_tags', [ 
    //.........