
Hello!
I'm working on migrating a project from Airtable to Appwrite, but I am a little confused about how to handle my schema.
Background: My site is a public listicle, and un-authenticated users fill up various forms to enquire about various properties on the site.
Currently:
- I have one table, which we can call 'Form Submissions' (containing user email, and info about the properties they enquiring about)
- I have a second table, which we can call 'User Callback Requests' (again, containing user mail, and info specific to their call back requests)
Problem:
- I am required to create a new table this time, called "User Activity". The purpose of this table is to be a unique list of user emails, user activity info (incremental count of form Submissions table, as incremental count from Callback Requests table).
- The above logic should be triggered automatically update at every document inserted into the two other tables mentioned above.
- I know with Postgresql i could've made triggers to handle this, but how do I do this in App Write?

You can create an Appwrite function to trigger on document creation.
In depth guide on functions: https://appwrite.io/docs/functions

Ah! Thanks Stephen!
So I'd basically need to maintain a separate codebase in a sense, to handle this. Got it.
Within the function, Is there a way I can ascertain which document was JUST updated (that triggered this function)? Or do I just need to pull all documents that were created in the last X minutes and ascertain which one triggered the function?

The APPWRITE_FUNCTION_EVENT_DATA
variable will have the newly updated document (for an update document event)

Thank you so much! Would this also trigger when a document is created?
I can't find a documentation page on this, if you could point me to that it'll be super helpful.
Thanks @Steven!

Yes document creation is an event too. The link to all the events is in the first paragraph

You're the best, Steven! Thank you
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
- Fail to receive the verification email a...
I added my email address to prevent it from showing "appwrite," but now I'm not receiving emails for verification or password resets. The function appears to be...
