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
- Quota not resetting
hi, im using appwrite's free tier plani hit my read limts last month and the billing cycle said it would reset on june 4th but that is today, the billing cycle ...
- Realtime Error Invalid query: Syntax err...
I was test driving Self-Hosted Appwrite for my use with Swift IOS apps as a backend while back and after successful trials, I started to move to incorporate int...
- TSL Certificate Issues
Hi Appwrite Discord Community, I got a problem with my Self-Hosted instance. I only want, that I can use my programm with the Appwrite Backend without .selfSig...