sequelize seed 无法在 SQLite 中插入数据
sequelize seed unable to insert the data in SQLite
我正在尝试使用 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
,它们都 运行 成功了,但是数据没有插入到 table
数据没有被插入。我做错了什么吗?
这似乎是 sequlizer
的问题,在 return
声明后它无法处理 space 换行符
module.exports = {
up: function(queryInterface, Sequelize) {
//old code
//return
// queryInterface.bulkUpdate('subject_tags', [
//new code
return queryInterface.bulkUpdate('subject_tags', [
//.........
Javascript 会在悬挂的 return
语句后自动添加 semi-colon。
它没有到达 bulkUpdate
代码。
我正在尝试使用 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
,它们都 运行 成功了,但是数据没有插入到 table
数据没有被插入。我做错了什么吗?
这似乎是 sequlizer
的问题,在 return
声明后它无法处理 space 换行符
module.exports = {
up: function(queryInterface, Sequelize) {
//old code
//return
// queryInterface.bulkUpdate('subject_tags', [
//new code
return queryInterface.bulkUpdate('subject_tags', [
//.........
Javascript 会在悬挂的 return
语句后自动添加 semi-colon。
它没有到达 bulkUpdate
代码。