Skip to content
Back

Issue with `listDocuments` when using query modifiers

  • 0
  • Self Hosted
  • Databases
  • Web
Ahrary
6 Jun, 2025, 10:38

Hello, Appwrite team!

I'm having an issue with listDocuments when using query modifiers:

Environment:

  • Self-hosted Appwrite (Version 1.4.13) installed inside Caprover
  • Next.js (node-appwrite@17.0.0 )

Issue:

  • The listDocuments without any queries returns documents well
  • It fails when adding queries (even simple ones), I get 500 error

Example that fails:

TypeScript
const docs = await databases.listDocuments(
  "db",
  "recipes",
  [
    Query.equal("language", "en"),
    Query.equal("status", "published")
  ]
);```

**What I've tried:**
Created indexes for all required attributes
Verified attributes exist in the collection
Tested with different query combinations

**Question:**
What could be causing queries to fail despite proper indexes? Are there special requirements for Enum attributes? 

**Addintional DB Info:**
```json
{
   "$id": "recipes",
   "databaseId": "db",
   "enabled": true,
   "documentSecurity": false,
   "attributes": [
     "title",
     "slug",
     "description",
     "prepTime",
     "cookTime",
     "servings",
     "difficulty",
     "authorId",
     "tags",
     "productIds",
     "language",
     "views",
     "featuredImage",
     "likes",
     "status"
   ],
   "indexes": [
     {
       "key": "status_idx",
       "attributes": [
         "status"
       ]
     },
     {
       "key": "views_idx",
       "attributes": [
         "views"
       ]
     },
     {
      "key": "createdAt_idx",
       "attributes": [
         "$createdAt"
       ]
     },
     {
       "key": "status_views_idx",
       "attributes": [
         "status",
         "views"
       ]
     },
     {
       "key": "language_idx",
       "attributes": [
         "language"
    ]
     },
     {
       "key": "status_createdAt_idx",
       "attributes": [
         "status",
         "$createdAt"
       ]
     },
     {
       "key": "language_status_idx",
       "attributes": [
         "language",
         "status"
       ]
     }
   ]
 }
},```
TL;DR
Issue: `listDocuments` function with query modifiers is causing a 500 error despite having proper indexes. Solution: Ensure there are no typos in the attribute names, and consider converting the Enum attributes to strings for compatibility.
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