我正在尝试选择嵌套关系字段,并遵循docs。但是,下面的查询只给出了id评级和考核字段。我遗漏了什么?
// in user entity
@OneToMany(() => Review, (review) => review.by, { orphanRemoval: true })
reviews = new Collection<Review>(this)
// in review entity
@ManyToOne(() => User)
by: User
...
const reviews = await DI.reviewRepository.find(
{ service: id },
{
populate: {
by: LoadStrategy.SELECT_IN,
},
fields: ["id", "rating", "review", { by: ["id", "firstName", "lastName"] }],
},
)
```
"@mikro-orm/core": "^4.5.4"
"@mikro-orm/sqlite": "^4.5.4"发布于 2021-05-12 15:33:46
通过将关系实体包含在字段中,我成功地使其正常工作
...
fields: ["id", "rating", "review", "by", "by.firstName", "by.lastName"]
...https://stackoverflow.com/questions/67498772
复制相似问题