Back

[SOLVED] CRUD question (Flutter)

  • 0
  • Flutter
safwan
3 Apr, 2023, 09:50

but you can't show it without a known id

TL;DR
The user had a question about displaying data from a document in Flutter using a ternary operator. Another user suggested adding an index for the field and provided code for querying the database. There was also a mention of managing state with a state manager or reactive code. The user then asked how to specify displaying text from a document that contains a specific name. Another user advised considering collection and document permissions and using the `databases.listDocuments` function. They mentioned that if the function returns an empty result, there are no documents for that user and it should display the option to register. If it returns items, it should display them on the screen
safwan
3 Apr, 2023, 09:51

as i said when you're showing data, use the document id

safwan
3 Apr, 2023, 09:51

make a list or something that stores the ids of all the documents for that user

safwan
3 Apr, 2023, 09:51

then use the correct id from the list to show the data

safwan
3 Apr, 2023, 09:51

and update

Chewbacca
3 Apr, 2023, 10:43

I don't quite understand, but I'll try to do something 😅

safwan
3 Apr, 2023, 10:58

okay how do you plan on display data?

safwan
3 Apr, 2023, 10:58

where will you get the data from?

Chewbacca
3 Apr, 2023, 12:16

from the database 😅

Chewbacca
3 Apr, 2023, 12:16

I will show you

Chewbacca
3 Apr, 2023, 12:16
safwan
3 Apr, 2023, 12:17

exactly

safwan
3 Apr, 2023, 12:17

you're fetching the data from the database

Chewbacca
3 Apr, 2023, 12:17

Yeah

safwan
3 Apr, 2023, 12:17

and to pinpoint which document you're fetching, you're using documentId right?

Chewbacca
3 Apr, 2023, 12:19

Yes

Chewbacca
3 Apr, 2023, 12:20

I just made data write, I don't know how to read data withou document id

rafagazani
3 Apr, 2023, 13:42

Consider the collection and documents permissions. If using documents permission, appwrite will only return the documents that the user has read permissions for, then you could use databases.listDocuments if it returns empty then there is no document for that user, it would display the option to register. If it returned items, it would display on the screen and have the information to update

Chewbacca
3 Apr, 2023, 19:55

it's more clear to me. And how can I specify that I need to display text from a document that contains name: Max, for example, thanks

rafagazani
3 Apr, 2023, 20:05

add an index for the field. then databases.listDocuments( databaseId: databaseId, collectionId: collectionId, queries: [Query.search('you_field', 'Max')]);

Chewbacca
3 Apr, 2023, 20:29

Thanks

rafagazani
5 Apr, 2023, 20:28

@Chewbacca Do you have any more questions? could you mark it as solved?

Chewbacca
5 Apr, 2023, 20:29

No, I don`t. I forgot to add SOLVED, thanks

Chewbacca
5 Apr, 2023, 20:30

[SOLVED] CRUD question (Flutter)

pandemoniun
5 Apr, 2023, 21:18

I resolve that problem with a ternary operator. For example if you a fetching a list, if it's empty a text : no documents now, and if it's has items you diplay it. somelist.isempty ? Text('No elements) : list(), and you must manage state with state manager o with reactive code

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