Values based upon aggregating relations? #12050
|
Hello! model Book {
id String @id @default(auto()) @map("_id") @db.ObjectId
pages Page[]
totalPages Int @default(0)
}
model Page {
id String @id @default(auto()) map("_id") @db.ObjectId
bookId String @db.ObjectId
book Book @relation(fields: [bookId], references: [id])
pages Int @default(0)
}Thank you :) |
Replies: 2 comments
|
Hey @daxidngyn 👋 , This is not possible with Prisma today. If you have an idea for how we could design a solution, please open a feature request! In the meantime, you could create a utility function to sum up the pages for a given book, or explore Prisma middleware to implement similar functionality. Let me know if I can clarify anything! |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that have already been marked as answered but remain open. If this discussion still requires further input or clarification, feel free to reopen it or start a new one with updated details. Your contributions are invaluable to the community, and we’re here to help! For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and ongoing support of the Prisma community! |
Hey @daxidngyn 👋 ,
This is not possible with Prisma today. If you have an idea for how we could design a solution, please open a feature request!
In the meantime, you could create a utility function to sum up the pages for a given book, or explore Prisma middleware to implement similar functionality.
Let me know if I can clarify anything!