Back

how to get key:value pair data from Document Object (Database)

  • 1
  • Tools
  • General
  • Databases
  • Apple
  • Self Hosted
Nico
8 Jun, 2023, 07:27

Hi, everyone.

I am pretty new here and I have a problem with gathering data from the Database.

So far I managed to sucessfully create a session with user authentication. and executing basic functions.

But now I am stuck when I want to extract data from the response I get when excecuting following function (Picture 1)

The output of this function is (Picture 2)

My Attributes look like that (Picture 3)

I want to extract the attributes and use it in further functions but I can´t wrap my head around how to extract this data.

Maybe someone can help me get on the right path to solve this issue.

TL;DR
Title: Need help extracting key:value pair data from Document Object in Database Message: User is having trouble extracting data from a Document Object in the database. They want to use the extracted data in further functions. They have shared the code they have tried and the output they are currently getting. Looking for guidance on how to properly extract the data from the Document Object. Solution: Removing the "queries" on the code might solve the issue. Also, the user can try using the `String(describing: document)` function to get a better understanding of the type of the variable.
Bouahaza
8 Jun, 2023, 10:56

Try to remove queries on your code ? It not exist on getDocument endpoint

Bouahaza
8 Jun, 2023, 10:58

From doc print(String(describing: document)

Nico
8 Jun, 2023, 13:55

Hi, Thanks for the response. I did what you said but the print statement you are refering only gives me the type of the variable (AppwriteModels.Document<Swift.Dictionary<Swift.String, JSONCodable.AnyCodable>>) but how do I extract this ?

Bouahaza
8 Jun, 2023, 14:10

I not use Swift so can't help more sry. Need to wait some apple developpers answer

Nico
11 Jun, 2023, 12:05

Hey @Steven thanks for the link I better understand now how to do it. based on this project I started to rework my code and I am now facing an issue with the "@Published var user: User?" from AuthVM.

Nico
11 Jun, 2023, 12:06

is this an old implementation which is not working anymore with newer appwrite versions ?

Drake
11 Jun, 2023, 14:00

I'm not sure exactly...the only thing I can think of is that you need to pass some type for the user preferences

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