Skip to content
Back

Update Document - GO

  • 0
  • REST API
Alperen
26 Jun, 2025, 23:43

Hello Appwrite team, currently I am having trouble updating collection documents on GOlang . Can you help me with that?


the README on GitHub is stale while the Quick-Start guide was written for the latest SDK. The README still shows the old v0.6.x API (for Appwrite ≤ 1.3) – e.g. appwrite.NewDatabase(client) and databases.UpdateDocument(collectionID, …) Beginning with sdk-for-go v0.7.0 (released 18 May 2025, compatible with Appwrite 1.7 +), the SDK was regenerated: Service names became plural (NewDatabases, NewUsers, …). All database methods now start with the database ID: CreateDocument(databaseID, collectionID, …) etc. The fluent client builder moved to functional options: appwrite.NewClient(appwrite.WithEndpoint(…), appwrite.WithProject(…), appwrite.WithKey(…)) The Quick-Start page reflects this new API, but the repository README hasn’t been updated yet, so anyone who copies the README code against v0.7.0+ (the default you get with go get github.com/appwrite/sdk-for-go) will see compiler errors.

TL;DR
Developers fixed an issue where credits weren't updating in GO. They switched to functional-option parameters, and one place was still using the old positional style. To fix, pass an option produced by WithUpdateDocumentData instead of a raw map. Remember, README on GitHub is stale; Quick-Start guide aligns with latest SDK. Update your code accordingly.
Alperen
26 Jun, 2025, 23:54

Issue is fixed, you may. close the ticket.

sdk-for-go v0.7.0 and the user’s credits are updated correctly after every successful “claim” call. What changed sdk-for-go v0.7.0 switched every write-style method (Create, Update, …) to functional-option parameters instead of positional arguments. Only one place in your backend still used the old positional style: databases.UpdateDocument(...) inside handleClaimPurchase.


_, err = databases.UpdateDocument( dbId, appUsersCollectionId, req.CustomerUserID, databases.WithUpdateDocumentData(map[string]interface{}{ "generation_credits": newTotalCredits, }), )


We pass an option produced by WithUpdateDocumentData instead of a raw map

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