Back

[SOLVED] How to generate id like admin dashboard in android sdk

  • 0
  • Android
Andrewwww
9 Mar, 2023, 13:32

I try to put document id in an field of document in android sdk

TL;DR
The OP wanted to generate an ID similar to the admin dashboard in Android SDK. They were asking about listening to all documents, but were not receiving any. Suggestions were made to listen to specific collection changes or to use `listDocuments` query to get specific document IDs to subscribe to. It was also clarified that querying in realtime is not possible, but subscribing to all document changes and filtering out unwanted ones using `if` statements is a viable option. UUID was suggested as a solution, and the OP confirmed that it worked. They also wanted to understand how to have the same document ID in a field, to which it was explained that `
Christy Jacob
9 Mar, 2023, 14:15

Hey could you please explain the issue, I don't think I understood

Binyamin
9 Mar, 2023, 15:48

If you mean generate a unique id you can use this ID.unique(), For more details look here https://appwrite.io/docs/getting-started-for-android#makeRequest

Andrewwww
9 Mar, 2023, 18:22

If I use ID.unique() the result is String = "unique()"

Andrewwww
9 Mar, 2023, 18:22

And I need something like this 64095923cf64fe976024

Andrewwww
9 Mar, 2023, 18:25

Isn't a issue I need to put in a id filed the same documentId value

Drake
9 Mar, 2023, 18:55

This is the expected behavior. When unique() is processed by the server, it's converted to a unique id like 64095923cf64fe976024

Andrewwww
10 Mar, 2023, 08:20

ok but is converted in the same unique code, because I need it to be the same code (documentID with my id field)

Meldiron
10 Mar, 2023, 09:06

Do I understand correctly you need attribute on a document which holds the same value as the document ID? Why do you need that? When reading documents, you can access document if under .$id.

Andrewwww
10 Mar, 2023, 09:06

yes

Andrewwww
10 Mar, 2023, 09:07

i resolved this with UUID it's ok

Andrewwww
10 Mar, 2023, 09:07

It's possible to put query on realtime?

Meldiron
10 Mar, 2023, 09:09

There are multiple channels you can subscribe to regarding realtime: https://appwrite.io/docs/realtime#channels

Querying isn't really possible, but you can simply subscribe to all document changes. Then, when payload arrives, you can use if statements to filter out those you don't want.

No need to be worried about performance/network too much, as you only get realtime updates about documents you have read permissions to.

Meldiron
10 Mar, 2023, 09:09

Alternativelly, you could do listDocuments query to get IDs of documents you are looking for. Then, subscribe to only those documents. Might be viable depending on your use case

Andrewwww
10 Mar, 2023, 09:18

and realtime is called for each colletion update?

Meldiron
10 Mar, 2023, 09:40

Depending on what you listen to. You can listen to collection changes, collection creation, document changes, functions, executions.. There is a lot you can subscribe to

Andrewwww
10 Mar, 2023, 10:00

And if I want to listener all documents it's ok "databases.${db_id}.collections.${ads_id}.documents.*?

Andrewwww
10 Mar, 2023, 10:01

I don't receive documents

Andrewwww
10 Mar, 2023, 10:19

And if I want to listener all documents it's ok "databases.${db_id}.collections.${ads_id}.documents.*?

Meldiron
10 Mar, 2023, 11:55

You need to use those channels

Andrewwww
10 Mar, 2023, 14:04

Thx

Drake
10 Mar, 2023, 19:13

[SOLVED] How to generate id like admin dashboard in android sdk

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