Back

Relationship attribute unexpectedly creating document

  • 0
  • Databases
Arrow
1 Jul, 2023, 08:37

Hello there,

I have a Relationship attribute as shown in the picture. I use pre-existing doctor documents to create a relationship and I noticed that every time I create a document with that relationship set with an existing document, the existing document gets created with a unique id. Is that unusual or is the intended behavior? Thanks

TL;DR
The user is experiencing unexpected behavior with relationship attributes in their production project. They want to clarify how relationships work in Firestore. They are specifically asking about creating a document in one collection with a relationship to an existing document in another collection. They mention that when they create a document with an existing relationship, the existing document gets created with a unique id. The user is seeking clarification on whether this is unusual or intended behavior. No solution is provided in the thread.
Drake
1 Jul, 2023, 14:08

Existing document gets created with a unique id? What do you mean?

Arrow
1 Jul, 2023, 18:49

I might have misunderstood on how Relationships exactly work. So let me get it straight: Relationship attributes creates a link between documents right?

So for example if collection A has relationship with documents in collection B, and if we want to create a document in collection A with a relationship from a document of collection B that already exists, should the first document from collection A (the one we create) cause the creation of a new document (the one we want to build a relationship with) in collection B?

Arrow
1 Jul, 2023, 18:50

That seems a little confusing

Drake
1 Jul, 2023, 19:27

You can create a document in the related collection or link an existing.

Maybe you can share your code

Arrow
1 Jul, 2023, 20:14

I implemented that in a production project and I had to quickly find another alternative. I will try to replicate that and share the code

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