matt murphy
06/14/2022, 10:49 AMTicket
model and a TicketTag
model, pretty much building a support ticketing system, however, I wish to add tags.
pretty much how it's documented to implement such a feature is to use a many-to-many implementation as so:
model Ticket {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
editedAt DateTime?
createdAt DateTime
ticketTags TicketTag[] @relation(fields: [ticketTagIds], references: [id])
ticketTagIds String[] @db.ObjectId
user User @relation(fields: [userId], references: [id])
userId String @db.ObjectId
}
model TicketTag {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
description String?
attributes Json
editedAt DateTime?
createdAt DateTime
tickets Ticket[] @relation(fields: [ticketIds], references: [id])
ticketIds String[] @db.ObjectId
}
But it seems incredibly unoptimized to stack for example 50,000 tickets into the ticketIds
field on the TicketTag
, as I'm aware MongoDB has a 16MB document limit.
My question is, is how can I get only Ticket
to store the ticketTagIds
without also doing the same on TicketTag
modelmatt murphy
06/14/2022, 10:54 AMmodel Post {
id String @id @default(auto()) @map("_id") @db.ObjectId
categoryIDs String[] @db.ObjectId
categories Category[] @relation(fields: [categoryIDs], references: [id])
}
model Category {
id String @id @default(auto()) @map("_id") @db.ObjectId
postIDs String[] @db.ObjectId
posts Post[] @relation(fields: [postIDs], references: [id])
}
matt murphy
06/14/2022, 11:06 AMNurul
06/16/2022, 1:16 PM