Back

Create FK field ClientId or create relationship field

  • 0
  • Self Hosted
  • General
Suiii
12 Nov, 2023, 05:22

does relationship property working the same as adding FK in another collection

TL;DR
The user is asking about creating a relationship field or a foreign key field. They mention that the configuration is different depending on whether the information is shown in both collections or only one. There is confusion about the two-way nature of the relationship. The user is referred to the documentation for more information. Solution: The user is provided with an example code snippet for creating a relationship attribute with a two-way relationship. The onDelete property is set to "cascade". Finally, the user asks if the relationship property works the same as adding a foreign key in another collection.
Suiii
12 Nov, 2023, 05:32

await databases.CreateRelationshipAttribute( databaseId: "marvel", collectionId: "movies", relatedCollectionId: "reviews", type: "oneToMany", twoWay: true, key: "reviews", twoWayKey: "movie", onDelete: "cascade");

Suiii
12 Nov, 2023, 05:32

what is twoWay mean?

Drake
12 Nov, 2023, 05:47

Yes

Drake
12 Nov, 2023, 05:48
Suiii
12 Nov, 2023, 05:50

I have read , missing some part ?

Drake
12 Nov, 2023, 05:50

What do you mean?

Suiii
12 Nov, 2023, 05:51

I dont see the explanation of twoWay

Drake
12 Nov, 2023, 05:52

Did you not see this?

Drake
12 Nov, 2023, 05:52
Suiii
12 Nov, 2023, 05:52

😂 nope

Suiii
12 Nov, 2023, 06:31

so two way, it means creating from either side is the same right

Drake
12 Nov, 2023, 06:44

Not exactly. It won't be the same for many to one or one to many. And on delete is different

Suiii
12 Nov, 2023, 06:47

oh, I tested, it is just way to config, if the info to be shown in both collection or only one collection of the relationship

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more