I'm new to Prisma. Prisma has definitely saved my ...
# orm-help
s
I'm new to Prisma. Prisma has definitely saved my time, but I'm also running into couple of problems with querying. Here is a specific one: (Prisma + MongoDB + Remix) I've a ticket collection, and it has a reply field which is an array of objects. reply object has agentId field, which is mapped to id of Agent collection. Agent collection has agents name and photo. Now how do I write a query to fetch a document from ticket collection, along with name and photo of the agent in the agentId present in reply field of Ticket collection. I tried searching for it online, but I'm still confused as to how to do that. Any help is much appreciated.
👀 1
r
Hi @Satish 👋 Can you please share your schema file?
👋 1
s
model Agent {
agentId   String    @id @default(auto()) @map("_id") @db.ObjectId
createdAt DateTime  @default(now())
updatedAt DateTime  @updatedAt
name      String
role      Role      @default(value: AGENT)
email     String    @unique
password  String
dob       DateTime?
photo     String
status    String?
twitter   String?
github    String?
verified  Boolean   @default(false)
Ticket    Ticket[]
snooze    Snooze[]
}
model Ticket {
ticketId  Int    @id @map("_id")
status    TicketStatus @default(NEW)
agent     Agent?    @relation(references: [agentId], fields: [assignee])
assignee  String    @default("Support")
followers String[]  @default([]) @db.ObjectId
uuid      String?
platform  String?
raddress  String?
xumm_app_info String?
kyc Boolean @default(false)
pro Boolean @default(false)
name String?
createdAt DateTime  @default(now())
updatedAt DateTime  @updatedAt
replies Replies[]
title String
question String
media Media?
}
type Replies {
replyId Int?
createdAt DateTime?  @default(now())
text String?
agentId String? @db.ObjectId
visibility Boolean  @default(true)
flag Boolean @default(false)
}
👀 1