I understand we need to add the event to appwrite.json. But even after specifying it in json can't add event
{
"projectId": "hidden",
"projectName": "hidden",
"events": [
"databases.*.collections.chat.documents.create"
]
}
This is how my appwrite.json looks currently
can't add event What do you mean?
@Steven I am trying to add an event that will automatically trigger a function when any document inside the chat collection will be created. But as soon as I go to the appwrite cloud and try to create the event through the create event button and put in all details it is added but disappears on refresh
Events disappear after refreshing page
Did you click on update after adding the event?
You definitely should put it in your appwrite.json, but that's the wrong place to put it. It should go under your function
I see, can you guide me to where I can find an example appwrite.json file specific to this
Did you initialize your function with appwrite init function?
No, I created it directly in cloud and then deploy using appwrite cli
Here are the docs: https://appwrite.io/docs/command-line-deployment
Thanks @Steven ✨
@Steven I tried putting events under functions but still not working. I even tried creating function using appwrite init function and then adding an event and then updating the function
But everytime the event is sent as empty to the cloud by cli
{
"projectId": "hidden",
"projectName": "hidden",
"functions": [
{
"$id": "hidden",
"name": "createChatCollection",
"runtime": "dart-2.17",
"path": "functions/createChatCollection",
"entrypoint": "lib/main.dart",
"ignore": [
".packages",
".dart_tool"
],
"execute": [],
"events": [ "databases.*.collections.chat.documents.*.create"
],
"schedule": "",
"timeout": 15
}
]
}
This is how my appwrite.json looks currently
I found out the issue
We need to hit update, even after clicking on create in events
Without update it just vanishes
Create event already has create button, so shouldn't create add the event instead of having to click on two buttons. I think it's a bit confusing for new comers
how did you "update the function"
I updated from cloud console of appwrite (By clicking add event button)
if you update in the console, your appwrite.json will be out of sync. i highly recommend updating in your appwrite.json and then deploy with appwrite deploy function
No I understand that, I wanted to say that to update in console we are having to click on three buttons. "+ Add Event" -> "Create" -> "Update". I think if we didn't need to click on the last update button it would have been better from a UX point of view
[SOLVED] Events disappear after refreshing page
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Appwrite Storage error 503s for automate...
I'm facing error 503s from Appwrite after about 5-6 seconds of making AI requests from my tool with images and files above 20MB (=> not inline base64 used, but ...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...