Back

How to call the interface once to query Documents through Document ids?

  • 0
  • Web
oldbird
17 Dec, 2023, 16:17

How to call the interface once to query Documents through Document ids?

TL;DR
The user is asking how to query documents using document IDs. They suggest saving everything in the same document but note that it can degrade performance. They also propose having a separate collection for followers with attributes for User ID and Article ID. They want to know how to call the interface once to query documents using Document IDs. Solution: One option is to use the `listDocuments` method with a query that includes `Query.equal("$id", ["[DOCUMENT_ID_1]", "[DOCUMENT_ID_2]", ...])`. This will allow you to query documents using specific document IDs.
oldbird
17 Dec, 2023, 16:18

I have an article entity and I need to find out who has followed this article. I need to know the names of these followers. What is recorded in my article entity is the ID of the followers. I think one-to-many scenarios like this are very common.

D5
17 Dec, 2023, 16:20

I would have a collection called followers and have there 2 attributes:

  1. User ID
  2. Article ID

Then an users collection with each user name

D5
17 Dec, 2023, 16:21

Saving everything in the same document will degrade performance

ideclon
17 Dec, 2023, 17:13
TypeScript
databases.listDocuments("[DATABASE_ID]", "[COLLECTION_ID]", [
  Query.equal("$id", ["[DOCUMENT_ID_1]", "[DOCUMENT_ID_2]", ...]),
]);
ideclon
17 Dec, 2023, 17:14
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