This is btw the exact error I receive, it basicall...
# orm-help
n
This is btw the exact error I receive, it basically says I can only use a relation with a name, so no
INLINE
Copy code
× The relation field `createdBy` must specify a `@relation` directive: `@relation(name: "MyRelation")`
× The relation field `members` must specify a `@relation` directive: `@relation(name: "MyRelation")`
l
it’s saying that because you have two implicit relations with
User
, so you need to give it a relation name so that prisma can tell the difference between the two
Copy code
type User {
    id: ID! @id
}

type Company {
    id: ID! @id
    createdBy: User @relation(name: "CompanyCreatedByUser")
    members: [User!]! @relation(name: "CompanyMembers")
}
something like that
n
I don't understand what is implicit and explicit in this case i guess 😞
hmm
🤔
So we don't specify it on the
User
type then?
it is more of giving the relation a name?
l
for this error yes
n
So why doesn't it generate a random one then?
l
ask the devs haha i don’t know
n
🙂 True, thanks for the help!
Kind strange
l
no worries
n
kind stranger*
So what do you do?
l
i’m a front-end developer for a Canadian-based ready-to-eat company
are you based in the US?
n
Ouch...
Copy code
Company
    × You are trying to set the relation 'CompanyCreatedByUser' from `Company` to `User` and are only providing a relation directive with a name on `Company`. Please also provide the same named relation directive on the relation field on `User` pointing towards `Company`.
    × You are trying to set the relation 'CompanyMembers' from `Company` to `User` and are only providing a relation directive with a name on `Company`. Please also provide the same named relation directive on the relation field on `User` pointing towards `Company`.
Sounds cool 🙂
What is a front-end dev doing in a prisma slack channel? 😛
I'm not,
I'm in Belgium 😉
l
ooooh
have you heard of Hello Fresh then?
basically the same concept, but in Canada
n
Yes, it's growing quite good I think
l
for some reason i’ve been assigned the task of adding prisma to our stack
so here i am haha
n
o.O
Oh boy
It took me a while to get my head around it, now it works like a charm though
j
I convinced them to use prisma, and i think he hates me now
n
except for these relations, I just don't understand it yet
l
we’re essentially a startup company, so each dev has to be flexible 😉
n
aka "you can do this right?"
l
@Jared hahahaha
n
"right?!"
@jared What have you done
No really, prisma is gold
j
¯\_(ツ)_/¯
now he can renegotiate his salary as a full-stack dev
n
👍 true
Any thoughts on the error btw? 🙂
l
like i said, you need to define the relation for both
on top of giving them a name
j
use a name like "somethingToOtherThing"
and put it on both items that are related
unless you use link: INLINE
then you dont need
that's for one-to-many
many-to-many use 'link:TABLE' and give it a name
n
Can you show me how to put it on the
User
model as it 😕
I can't seem to get this right...
shaaameeee
j
Copy code
utilities: Utilities
    @relation(name: "ListingToUtilities", link: TABLE, onDelete: CASCADE)
thats the syntax
n
can show me the part of Utilities type?
j
listing: Listing! @relation(name: "ListingToUtilities")
the table thing only needs to be on one side
l
but the name on both so prisma understands
j
ya
and the result is a join table in the db
l
happy prisma happy life