This has been probably asked before, but can't see...
# orm-help
e
This has been probably asked before, but can't seem to find the answer in the docs. In a Prisma datamodel, is it possible to create a type which can have different parents, and point to that parent directly? Example bellow i point with an ID, and maybe have a string for parentType. But would prefer Stats to have
parent: User/Team!
directly.
Copy code
type User {
	id: ID! @unique
	stats: Stats
}
type Team {
	id: ID! @unique
	stats: Stats
}
type Stats {
	id: ID! @unique
	parent: ID! # ← Is it possible to make this relationship point to a Team or a User, depending on which it belongs to?
	parentType: String! # Is this needed? Is there a better approach?
}
j
Look at relations in the prisma docs. Prisma.io
e
I have, don't see anything about a relation being able to be multiple types. But isn't there some creative solution to deal with that in a better way?
j
User and Team are the same. Id and stats.
So maybe make a field UserTeam with id, stats, type. For type use a enum USER or TEAM
e
Cheers, yeah was thinking to put type as an enum. Guess I was looking for something that doesn't exist.
Basically what I was looking for is
union
, except it's not supported yet: https://github.com/prisma/prisma/issues/165