Back

Document Update Success in Cloud Function Logs but Not Reflected in Database

  • 1
  • Self Hosted
  • Functions
theSugarManMMA
18 Aug, 2023, 11:22

Hello Appwrite Support Team,

I hope this message finds you well. I've encountered an issue related to updating a document in my Appwrite database via a cloud function.

I am currently using Appwrite version 0.12.4.202. I am attempting to update a document using a cloud function. Post-update, within the same function, I'm fetching the document from the database and printing the changed value to ensure the changes have been applied. According to the cloud function logs, this change appears to have been executed successfully, every time. However, when I inspect the document directly in the Appwrite console, the expected changes do not always happen.

While the change is consistent in the cloud function logs, it's reflected in the actual database only about 3/4th of the time. Interestingly, this inconsistency occurs even when the exact same user performs the actions in an identical manner.

This intermittent nature of the issue is puzzling, and I'm trying to understand the root cause. Please help me. Thank you.

TL;DR
The user is experiencing an issue where document updates in the Appwrite database via a cloud function are not always reflected in the database, despite success logs in the cloud function. The issue occurs intermittently and even with the same user. They are using Appwrite version 0.12.4.202. They are seeking help to understand the root cause. Solution: Upgrade to the latest version of Appwrite.
theSugarManMMA
18 Aug, 2023, 13:29

bump

Binyamin
18 Aug, 2023, 14:34

First, if can it's much recommend the upgrade to latest version (remember to upgrade and know the migration increment process)

As for your use-case How do you know that the transaction was indeed success, can you share the function code?

theSugarManMMA
18 Aug, 2023, 15:55

`db = Database(client); storage = Storage(client); Order order = Order.fromJson((await db.getDocument( collectionId: orderCollectionID, documentId: orderId)) .data);

order.status = 'COMPLETED';

await db.updateDocument( collectionId: orderCollectionID, documentId: order.id!, data: order.toJson()); print('Order Status Updated!'); Order orderVer = Order.fromJson((await db.getDocument( collectionId: orderCollectionID, documentId: orderId)) .data); print("ORDER STATUS CHECK: " + orderVer.status);`

theSugarManMMA
18 Aug, 2023, 15:56

and the function logs say: Order Status Updated! ORDER STATUS CHECK: COMPLETED

theSugarManMMA
18 Aug, 2023, 15:56

Meaning that it is updated, but somehow "reverts back"? I don't get it. Note that it works sometimes and does not sometimes

Binyamin
18 Aug, 2023, 16:25

What langauge it is?

Drake
18 Aug, 2023, 19:06

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

theSugarManMMA
18 Aug, 2023, 23:47

Dart

Drake
19 Aug, 2023, 00:23

are there audit logs for the document? it might be in the appwrite console, in the document...maybe one of the tabs

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