Skip to content
Back

Upsert Announcement: Swift Not Working

  • 0
  • Databases
  • Apple
  • Cloud
Jay
8 Jul, 2025, 19:59

With the Upsert announcement, we are not having success with upsert in Swift. We’ve tried the following

(from the docs)

do { let doc = try await databases.upsertDocument( databaseId: databaseId, collectionId: collectionId, documentId: ID.unique(), data: ["title": "New Title", "author": "New Author"] ) } catch { print(error.localizedDescription) }

and also

let bookToUpsert = Book(id: docId, title: "New Title", author: "New Author")

do { let doc = try await databases.upsertDocument( databaseId: databaseId, collectionId: collectionId, documentId: docId, data: bookToUpsert, nestedType: Book.self ) print(doc) } catch { print(error.localizedDescription) }

We have verified read and write permissions are enabled (we can create, read, update and delete documents)

Swift, macOS 15.3, Apple SDK 10.1.1

the result is simply

Server Error

in the console, with no details

Perhaps we are doing something wrong in our code? Also, what's the situation with ID.unique() - if the id is always unique won't it always create a new document?

TL;DR
Developers are experiencing issues with upsert in Swift after an announcement. They have tried using the provided code snippets but are receiving a "Server Error" with no details. They are unsure if there is an error in their code and have questions regarding ID.unique() always creating a new document.
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