I'm trying to create a many-to-many relationship between two models: Entity and Taransaction
model Entity {
id String @id @default(cuid())
name String
purchases Transactions[] // references the source field on Transaction
sales Transaction[] // references the destination field on Transaction
}
model Transaction {
source Entity
destination Entity
amount Float
date DateTime @default(now())
}
What I want is to be able to retrieve all the Entity's purchases which points to the source of the transaction and all the Entity's sales which points to the destination of the transaction.
My question is, what would the schema for this relation would look like using Prisma 2?