Вот мои настройки:
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
Edit:
Моя модель следующая. Я опубликую полезные данные как можно скорее.
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);
}
}