Hi, I'm trying to retrieve character documents which have an attribute "userId" from a query, but the response is always an empty document.
TypeScript
const response = await databases.listDocuments(
process.env.APPWRITE_DATABASE_ID,
process.env.APPWRITE_CHARACTER_COLLECTION_ID,
[
Query.equal('userId', userId),
// Query.select(["characterId"])
]
)
if (response && response.documents) {
log(response)
return {
success: true,
response,
total: response.total
};
} else {
return {
success: false,
message: "Received response in unexpected format",
data: response
};
}
Here are some things I've checked - ✅ Document exists with correct userId. ✅ Collection has permission for all users. ✅ collection has an attribute named userId which is also made an index. ✅ function executes, payload is recieved correctly.
Any help is appreciated.
TL;DR
Issue: Query always returns a document count of 0 even when there are matching documents.
Solution: Double-check the equality condition in Query.equal to ensure it matches the userId format. Check if userId is stored consistently in the database.Recommended threads
- Python TablesDB Rework
Hi, i starting to rework some older functions to TablesDB list_rows Method. I used list_documents with a resultset with worked fine. Now i tried to get all rows...
- HUGE OUTRAGE IN APPWRITE, I CANNOT ACCES...
I have 2k users trying to access, sending me messages. What am I supposed to do? Please solve this asap.
- All my apps are not opening now
All my apps are not opening now 200+ apps are not opening plz fast