Back

Updating the relationship, if I don't pass the previously linked ids then it's getting de-linked

  • 0
  • Databases
Vedsaga
17 May, 2023, 12:20

If I don't pass the previously linked IDs then all those linked ids are getting removed.... That seems very dangerous πŸ‘€

TL;DR
Summary: The user is discussing the issue of de-linking relationships and proposes using separate methods for de-linking and querying relationships. They also mention the problem of updating relationships in many-to-many scenarios and suggest creating a separate method for de-linking documents to avoid overriding existing relationships. They provide a link to a related issue on GitHub and express concerns about losing linked IDs if they are not passed in the update request. Solution: The user suggests creating separate methods for de-linking and querying relationships and recommends not overriding existing relationships but adding to them instead. They also highlight the problem of losing linked IDs and propose a solution of not removing linked IDs
joeyouss
17 May, 2023, 16:05

Hey - any example you can share that maybe you tried?

Vedsaga
17 May, 2023, 16:11

I mean, it's nested objects πŸ˜… 1st req Beat --> ["client1ID",]

2nd req

TypeScript
Beat
--> ["client2ID"]

now, first linked client get's removed if you don't pass in end 2nd request

Drake
17 May, 2023, 19:14

yes same as any array in Appwrite

Vedsaga
17 May, 2023, 19:15

mm, wish it was to way to mention to not override, that just simply add to existing relationship because imagine having 100+ document?

Vedsaga
17 May, 2023, 19:16

and in case of 1000+ doc πŸ‘€

Drake
17 May, 2023, 19:17
Vedsaga
17 May, 2023, 19:17

may be I guess we should create seperate method to de-link the document? and let the update simply add to existing relationship...

Drake
17 May, 2023, 19:18

That could work. Or you can update the relationship from the other side (assuming it's a two way one to many or many to one)

Vedsaga
17 May, 2023, 19:19

yaa, but in case of many-to-many that be problem

Vedsaga
17 May, 2023, 19:20

I guess, we should all together have seperate methods for de-linking and quering relationship because trying to fit it into well orgnaize methods might make existing method over-complicated & messy to maintain

Vedsaga
17 May, 2023, 19:22

or may be it could be other way around, having seperate method of partial update in that case will save rom needing to change in existing update function but simply need to write new one which just do partial addition

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