Back

[SOLVED] On Creating a Document does not trigger Function.

  • 0
  • Self Hosted
  • Functions
  • Databases
Shiba
30 Nov, 2023, 19:20
TypeScript
{
            "$id": "6568c7cb957338cbb5c5",
            "name": "latest_new_messages",
            "runtime": "dart-3.0",
            "execute": [],
            "events": ["databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.create"],
            "schedule": "",
            "timeout": 15,
            "enabled": true,
            "logging": true,
            "entrypoint": "lib/main.dart",
            "commands": "dart pub get",
            "ignore": [
                ".packages",
                ".dart_tool"
            ],
            "path": "functions/latest_new_messages"
        }

some how databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.create does not trigger the fuction but databases.* WORKS. and databases.*.collections.*.update does not

TL;DR
The user encountered an issue where the function was not triggered when creating a document. The problem was resolved by changing the event listener from `"databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.create"` to `"databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.documents.*.create"`. This change allows the function to listen to document creation within a specific collection. The user also mentioned that listening to all collections with the wildcard identifier `"
Binyamin
30 Nov, 2023, 19:22

This event will listen to any collection with 6562cf067d4ed0fc8b70 ID creation.

To listen to documents creation within a collection, you'll need to add one more identifier

Binyamin
30 Nov, 2023, 19:22
TypeScript
-databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.create
+databases.6562ce5dcb5c8d0b005e.collections.6562cf067d4ed0fc8b70.documents.*.create
Binyamin
30 Nov, 2023, 19:22

This way you will listen to the documents.*.create events and not for the collection create one.

Shiba
1 Dec, 2023, 05:27

<:appwriteheart:782571497393750036>

Ryan
1 Dec, 2023, 15:24

how did u do this please tell!

Binyamin
1 Dec, 2023, 15:25

Like so

Ryan
1 Dec, 2023, 15:26

ok thanks!

Drake
1 Dec, 2023, 17:26

[SOLVED] On Creating a Document does not trigger Function.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more