
Trying to execute a function when there is an update in a particular document ,this is my code and for some reason it is not working.

Maybe in this case you could use event triggers

The subscription never triggers?

@otik recommendation may be better for what you want, if you give us more details we can help you

Can you add a print before the if?
Does the user have access to the document you updated?

@Guille it is a CRUD application I am building,so when the user makes changes to the document,like an update on the status of a task , I wanted to trigger a real time notification to the user. But the function does not seem to b working

Follow Steven recommendation, check the document permission, I would suggest you to make the collection accessible to all users while you are working in this stage, then later you can focus on permissions.
After set the permission you should add a print to your code this way:
function realTime(database, collection, document) {
console.log({database, collection, document}); // check if subscription data is correct
client.suscribe(`databases.${database}.collections.${collection}.documents`, response => {
console.log(response); // read response
});
}

☝️ Yep permissions are important

Thank you I will try this

I have checked my permissions, the subscription doesn’t work on document update ,I just want to listen to an update in the attribute of a document.

you're missing a dot after documents

Yes I fixed that

But it still didn’t work

You need to subscribe to channels: https://appwrite.io/docs/realtime#channels

You're subscribing to events
Recommended threads
- The new Bulk API and Realtime updates
It seems that the new Bulk API doesn't actually send realtime updates which is making a huge problem for me. I also wanted to know different is it deleting mul...
- Which repo is used for cloud.appwrite.io...
I made a PR and it got merged into appwrite/console Repo. - It had this description: "The console that makes Appwrite tick from the browser" - I assumed this i...
- Send Team Invites w/o Owner Role
Hi there! I'm trying to get a specific bit of functionality set up in my application. I would like to be able to allow users to send Team Invite emails to oth...
