排序数据库错误,没有错误消息

时间:2018-11-25 15:49:59

标签: node.js postgresql express sequelize.js

这是我第一次使用PostgreSQL,我正在创建一个REST API,它使用sequelize来实现postgresql,expressjs和nodejs。
我创建了一个用户,每个用户都有很多包裹。我现在正在使用userId作为参考创建属于用户的地块。我不断收到数据库sequelize错误,并且没有消息。例程说,“ checkInsertTarget”。

错误消息

:not(a):not(b):not(label):not(form):not(abbr):not(legend):not(address):not(link):not(area):not(mark):not(audio):not(meter):not(b):not(nav):not(cite):not(optgroup):not(code):not(option):not(del):not(q):not(details):not(small):not(dfn):not(select):not(command):not(source):not(datalist):not(span):not(em):not(strong):not(font):not(sub):not(i):not(summary):not(iframe):not(sup):not(img):not(tbody):not(input):not(td):not(ins):not(time):not(kbd):not(var) {border:1px solid red;}

包裹迁移代码

// in magic.js
module.exports = (db) => (req, res, next) => new Promise((resolve, reject) => {
  // do magic here
})
  .then(data => next())
  .catch(error => res.status(501).send(JSON.stringify(error)))


// in index.js
const db = require('db-lib')
const magic = require('./magic')(db)
app.use(magic)

包裹型号代码

{
    "name": "SequelizeDatabaseError",
    "parent": {
        "name": "error",
        "length": 190,
        "severity": "ERROR",
        "code": "42703",
        "position": "48",
        "file": "d:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\parser\\parse_target.c",
        "line": "1033",
        "routine": "checkInsertTargets",
        "sql": "INSERT INTO \"Parcels\" (\"id\",\"name\",\"delivered\",\"presentLoc\",\"destination\",\"description\",\"createdAt\",\"updatedAt\",\"userId\") VALUES (DEFAULT,'Shoe',false,'Onitsha','ESUT','black shoe, size 34','2018-11-25 15:48:13.100 +00:00','2018-11-25 15:48:13.100 +00:00','3') RETURNING *;"
    },
    "original": {
        "name": "error",
        "length": 190,
        "severity": "ERROR",
        "code": "42703",
        "position": "48",
        "file": "d:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\parser\\parse_target.c",
        "line": "1033",
        "routine": "checkInsertTargets",
        "sql": "INSERT INTO \"Parcels\" (\"id\",\"name\",\"delivered\",\"presentLoc\",\"destination\",\"description\",\"createdAt\",\"updatedAt\",\"userId\") VALUES (DEFAULT,'Shoe',false,'Onitsha','ESUT','black shoe, size 34','2018-11-25 15:48:13.100 +00:00','2018-11-25 15:48:13.100 +00:00','3') RETURNING *;"
    },
    "sql": "INSERT INTO \"Parcels\" (\"id\",\"name\",\"delivered\",\"presentLoc\",\"destination\",\"description\",\"createdAt\",\"updatedAt\",\"userId\") VALUES (DEFAULT,'Shoe',false,'Onitsha','ESUT','black shoe, size 34','2018-11-25 15:48:13.100 +00:00','2018-11-25 15:48:13.100 +00:00','3') RETURNING *;"
}

包裹管理器

 'use strict';
    module.exports = {
      up: (queryInterface, Sequelize) => {
        return queryInterface.createTable('Parcels', {
          id: {
            allowNull: false,
            autoIncrement: true,
            primaryKey: true,
            type: Sequelize.INTEGER
          },
          name: {
            type: Sequelize.STRING
          },
          delivered: {
            type: Sequelize.BOOLEAN
          },
          presentLoc: {
            type: Sequelize.STRING
          },
          destination: {
            type: Sequelize.STRING
          },
          description: {
            type: Sequelize.STRING
          },
          createdAt: {
            allowNull: false,
            type: Sequelize.DATE
          },
          updatedAt: {
            allowNull: false,
            type: Sequelize.DATE
          },
          userId: {
            type: Sequelize.INTEGER,
            onDelete: 'CASCADE',
            references: {
              model: 'Users',
              key: 'id',
              as: 'userId',
            }
          }
        });
      },
      down: (queryInterface, Sequelize) => {
        return queryInterface.dropTable('Parcels');
      }
    };

1 个答案:

答案 0 :(得分:2)

我检查了数据库,看到一列我认为已删除的列。我必须先运行sequelize db:migrate:undo,然后再次进行sequelize db:migrate才能合并我的更改,即实际上删除该列。