Octavio Augusto Barbosa
11/26/2021, 3:26 PMasync listAccounts(user: Clients): Promise<AccountResponse[]> {
const accounts = await this.prismaService.accounts.findMany({
where: {
company: {
id: user.company.id,
deletedAt: null
}
}
})
return plainToClass(AccountResponse, accounts)
}
if i try a console.log( user ) i receive all data of clients and companyRykuno
11/26/2021, 11:31 PMOctavio Augusto Barbosa
11/29/2021, 11:20 AMuser.company.id
, the company object is include on findMany method, like this
return this.prismaService.clients.findMany({
where: {
//where condition
},
include: {
company: true
}
})
this is my Clients interface, created by prisma generate
export type Clients = {
id: number
surrogateKey: string
description: string | null
clientid: string
email: string
scopes: Prisma.JsonValue
role: clients_role
status: clients_status
companyId: number | null
createdAt: Date
updatedAt: Date
deletedAt: Date | null
}