Hello all! need some help my method below try to ...
# orm-help
o
Hello all! need some help my method below try to access user.company.id, company object has include in findUnique metod in my auth middleware. how i can access this data ?
Copy code
async 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 company
r
Can you rephrase or simplify? Sorry I know english probably isn’t your first language but I’ll try to help.
o
Sorry, my english sucks hahaha i try to get a value of
user.company.id
, the company object is include on findMany method, like this
Copy code
return this.prismaService.clients.findMany({
  where: {
    //where condition
  },
  include: {
    company: true
  }
})
this is my Clients interface, created by prisma generate
Copy code
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
}