gpt4 book ai didi

Nestjs Crud : Filter join request to return only data of current user

转载 作者:行者123 更新时间:2023-12-04 02:28:48 24 4
gpt4 key购买 nike

目前我在我的 Controller 中得到了他的:

@Crud({
model: {
type: Broker
},
query: {
join: {
user: {
eager: true,
exclude: ['password']
}
}
}
})
@Controller('broker')
@UseGuards(AuthGuard('jwt'))
export class BrokerController {
constructor(public service: BrokerService) {}
}

有一个 one to many 用户和经纪人之间的关系。我正在通过 jwt token 对用户进行身份验证,我需要过滤用户 ID 上的数据。有没有办法通过 Crud 配置来做到这一点?

最佳答案

您可以创建一个中间件,将用户 ID 添加到 session 中的 req.params。
这是一个技巧,但到目前为止我还没有看到其他解决方案

关于Nestjs Crud : Filter join request to return only data of current user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57692686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com