node.js - sequelize 种子无法在 SQLite 中插入数据

标签 node.js sqlite sequelize.js seeding sequelize-cli

我正在尝试使用 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)

我在种子文件中尝试了 bulkCreatebulkInsert ,它们都运行成功,但数据没有插入到表中
数据没有被插入。我做错了什么吗?

最佳答案

sequlizer 似乎有问题,在 return 语句之后它无法处理带有换行符的空格

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

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

关于node.js - sequelize 种子无法在 SQLite 中插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42326156/

相关文章:

sockets - 安装 Node http代理

node.js - 在 Windows 中创建 derbyjs 应用程序

java - 使用java代码将图片插入数据库(sqlite)。我应该怎么办?

android - 在 SQLite 中查询时是否可以将值从列拆分为行?

mysql - 使用sequelize更新字段

postgresql - Sequelize 中的 "increment"功能是否可以很好地扩展?

javascript - 如何使用javascript逐字节读取二进制文件?

node.js - 如何将 mp4 视频转换为 (.m3u8) 播放列表 nodejs

android - 获取游标对象时出现空指针异常

transactions - 如何在交易期间禁用特定的验证规则?