hi, is it possible to make a function event listen to a specific attribute in document ? And how can i do it.
What's your use case?
I want the function to check if this specific attribute had an update and then procceed to create another document based on the previous document to a collection that is read only.
I would create a duplicate collection that holds the last version of the document. Trigger the function on update of document in original collection and:
- Fetch document from other collection
- Compare
- Make sure to update the document in the other collection
There is an attribute that have three stages (waiting for approval, approved, denied). I want if the document attribute called status got updated to (approved), the function should executes grabbing some data from the document and creates a final document in another collection.
All of that in the server side I don't want to make it run manually from the client side.
Can you help me figure it out π« if you have a better solution.
I want this thing to only happen when the status is updated to (approved)
I just told you how π§
Yes, But i have to make it run on every update, is it possible to make it run on specific status on the status attribute.
Or do I have to run manually in the client side.?
Yes, function triggers on every document update in the collection
Then if i want to create the final document when the status changes to (approved), i have to run the function manually on the client side and give it the required variables.
Yes or no ?
Because if i make the event on update, the function would trigger on (waiting for approval) then would run on (approved) another time because all the stages count as an update
Yes, but it can just not create that final document
Alternatively, you can update the status using a function instead of updateDocument() client-side
I can make a manual excution for the function after the client side changes the document status to (approved) and send the document id to the function when executing so I can pull the data that i need to create the final document.
I never thought of thatπ
Uh I was suggesting to trigger the function based on the update event
Thanks i figured it out
Recommended threads
- My account is blocked so please check an...
My account is blocked so please unblock my account because all the apps are closed due to which it is causing a lot of problems
- Applying free credits on Github Student ...
So this post is kind of related to my old post where i was charged 15usd by mistake. This happens when you are trying to apply free credits you got from somewh...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...