Back

Realtime update events not triggering for document attribute with relationship

  • 0
  • Web
  • Realtime
Badr
7 Jan, 2024, 09:24

Hi everyone. Realtime event is not triggering when a document is updated. To give a bit of context, collection A and collection B exist such that there is a one to many relationship on an attribute on collection A. When a document is added on collection B, it's added automatically on collection A's field list.

Even though the document from collection A does update it's list with the new document from collection B, it doesn't trigger an event. When manually adding or removing the document from the list on collection A either through the SDK or through the console, the event does get triggered and a response is thrown in the code specified above. My permissions are set to "Any" checked for all read write perms.

This is the specific code that I'm using to subscribe to a document. When making a new message document on Message collection, the message gets added to a Room collection's messages list automatically because of the relationship - but the event does not trigger.

TypeScript
const unsubscribe = client.subscribe(
[`databases.${APPWRITE_DATABASE_ID}.collections.${APPWRITE_COMMUNITY_ROOM_COLLECTION_ID}.documents.${roomId}`],
  (response) => {
    console.log('[ChatContainer] New message event:', response);
  }
);

When I'm adding or removing message documents from Room collection's manually either through the console or SDK, this event gets triggered.

Any help will be appreciated, thanks!

TL;DR
Realtime update events are not triggering when a document is updated. This is happening in a situation where there is a one-to-many relationship between two collections. When a document is added in one collection, it is automatically added to the other collection's field list. However, the event does not get triggered in this scenario. The event does trigger when the document is added or removed manually through the SDK or console. The permissions are set correctly. Solution: There is a missing πŸ‘ emoji on the GitHub issue that addresses this problem.
Drake
8 Jan, 2024, 00:13

Yes, this is missing. There's a GitHub issue for this if you search for it

Drake
8 Jan, 2024, 00:13

I recommend adding a πŸ‘ to the issue

Badr
8 Jan, 2024, 07:17

thanks!

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