
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
- How to reduce DB Reads?
I just noticed that I hit the 500k db reads limit on my very small next js app with the most data being present in one collection having around 50 documents. ...
- Getting issue while migrating from Self ...
i try to migrating my project but when do this error come and dont allow to crate that migration
- Pending upload some file, but not for ot...
When upload this file, always got pending. But when I upload another file, it works. Why?
