Back

Trying to query by equals throws general_query_invalid exception

  • 0
  • Flutter
  • Cloud
Nico
21 Mar, 2024, 10:45

I'm trying to query my collection filtered by a contactId. This contact id references ids of items in another collection. By the documentation something like this:

TypeScript
var documents = _databases.listDocuments(
        databaseId: constants.databaseId,
        collectionId: constants.CollectionIds.feedEntries,
        queries: [Query.equal("contactId", contactId)]);

Should do the job fine, as the contactId attribute exists on the feedEntries collection and contactId is a String provided from other parts of the app.

But the code above throws this:

TypeScript
AppwriteException (AppwriteException: general_query_invalid, Invalid query: {"method":"equal","attribute":"contactId","values":["65fbf2e930f439e4eef7"]} (400))

What am I missing?

TL;DR
Issue: Attempting to query by equal method results in a general_query_invalid exception. Solution: Check the data type of the 'contactId' attribute. Ensure the contactId is a string data type in both the code and the database.
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