У меня есть две модели Post и User.
Я пометил свойство userId поста с помощью принадлежащего декоратору
@belongsTo(() => User, {keyTo: 'id', name: 'user'})
userId: number;
, но когда я использую фильтр включения для поста.
return await this.postRepository.find({
"include": [{
"relation": "user",
}
]});
Loopback выдает ошибку
Unhandled error in GET /posts: 500 Error: Relation "user" is not defined for Post model
at processIncludeItem (/node/posts/node_modules/loopback-datasource-juggler/lib/include.js:309:10)
at /node/posts/node_modules/loopback-datasource-juggler/lib/include.js:187:7
at /node/posts/node_modules/async/dist/async.js:3110:16
at eachOfArrayLike (/node/posts/node_modules/async/dist/async.js:1069:9)
at eachOf (/node/posts/node_modules/async/dist/async.js:1117:5)
at Object.eachLimit (/node/posts/node_modules/async/dist/async.js:3172:5)
at Function.Inclusion.include (/node/posts/node_modules/loopback-datasource-juggler/lib/include.js:185:9)
at /node/posts/node_modules/loopback-datasource-juggler/lib/connectors/memory.js:510:33
at process._tickCallback (internal/process/next_tick.js:61:11)