
Hello. We are trying out Appwrite. We've gone through the getting started and setup guide and are attempting to create a document, copy/paste from the Getting started website here https://appwrite.io/docs/products/databases/quick-start except we've moved the createDocument to it's own function
func createDocument() async throws { do { let document = try await databases.createDocument( databaseId: databaseId, collectionId: collectionId, documentId: ID.unique(), data: ["title", "hamlet"] ) print(document) } catch { print(error) } }
the My Books collection has an empty database with a single attribute "title" as String. When calling the function the return value is vague:
Invalid document structure: Unknown attribute: "0"
and the data is not written. Not sure where the "0" is generated from.
We think the api endpoint is correct "https://fra.cloud.appwrite.io/v1" however, the documentation does not match the website so we cannot verify.
One other note is that in the Quick Start guide, it says "You can skip optional steps." but it doesn't indicate which are optional, all of the steps following that statement? Perhaps some are required?

I can ans about the endpoint The new endpoint added few weeks ago the fra indicating the server location Although using the old one (the one in the documentation) will also work

Also
Your code has a mistake
data: ["title" : "hamlet"]
You have written , instead of :

awesome. I think the , was the issue! OE on that one. Thank you for catching my typo

I couldnt determine which optional steps you were talking about. Could you tell me about this step/s mentioned?

So its working now?

"Optionally, add a custom database ID" If you were talking about these part then this indicates either you can use ID.unique or just give a unique id according to your wish. So, lets say you have a collection and kind of want to have same id as the collection name You could do that.

Thanks for the followup. The guide here https://appwrite.io/docs/quick-starts/apple about 1/2 way down says "You can skip optional steps". We assume everything below that statement are "option steps" but were not sure.

Maybe they ment the account creation stuff I dont know about swift Maybe the data related to using Oauth by Apple is optional 🤷♂️ Like you could go without sign in if your app doesnt need it 🤷♂️

Got it. Thanks. It's 'working' but we are still trying to figure out what is returned from the queries. e.g. in Swift let documents = try await databases.listDocuments
and we are not sure the format of the returned data. Will keep digging in trying to find out.
Recommended threads
- Appwrite documents and Swift codable
The object I use to create a document is different than the object I receive when I list documents. Do I create an object that’s used to create a document and a...
- Swift: Response from .deleteDocument
According to the docs, in Swift when calling `databases.deleteDocument` the response is supposed to be 204 (No Content). However, we are finding the response is...
- Project Setup
Hi Appwrite Community. I would like to set up my Xcode Project with the Appwrite SDK. I can't get it to work. I hope somebody can help me with this. Thanks 🙂 ...
