AssertionError [ERR_ASSERTION]:表达式的计算结果为假值:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

这是我的设置:

CouchDB: 2.3.1
LoopBack: 1.11.2
NPM: 6.9.0

使用 LoopBack API Explorer,这是剩余的调用:

curl -X PUT "http://localhost:3000/skilltypes/0" -H  "accept: */*" -H  "Content-Type: application/json" -d "{json_here}"
http://localhost:3000/skilltypes/0
204 SkillType PUT success

在 Fauxton,我看到数据库中的记录。

但是,NodeJS 服务器崩溃并出现以下错误:

assert.js:350
    throw err;
    ^

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert(doc._id)

    at CouchDB.fromDB (/home/dan/projects/SkillType/my-app/node_modules/loopback-connector-couchdb2/lib/couchdb.js:163:3)
    at /home/dan/projects/SkillType/my-app/node_modules/loopback-connector-couchdb2/lib/couchdb.js:701:21
    at Request._callback (/home/dan/projects/SkillType/my-app/node_modules/nano/lib/nano.js:221:16)
    at Request.self.callback (/home/dan/projects/SkillType/my-app/node_modules/request/request.js:185:22)
    at Request.emit (events.js:189:13)
    at Request.<anonymous> (/home/dan/projects/SkillType/my-app/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:189:13)
    at IncomingMessage.<anonymous> (/home/dan/projects/SkillType/my-app/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-app@1.0.0 start: `node .`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/dan/.npm/_logs/2019-04-26T13_07_37_106Z-debug.log

编辑:

我的模型如下。我会尽快 post 一个有效负载。

import {Entity, model, property} from '@loopback/repository';

@model({settings: {"strict":false}})
export class SkillType extends Entity {
  // Define well-known properties here
    @property({
        type: 'number',
        id: true,
      })
      id: number;
  // Indexer property to allow additional data
  [prop: string]: any;

  constructor(data?: Partial<SkillType>) {
    super(data);
  }
}

在我看来,这像是 CouchDB 的 LoopBack 连接器中的错误。你能在 GitHub 上报告这个问题吗?

请关注项目的bug reporting guidelines