DocumentList response = await databases!.listDocuments(
databaseId: "*****",
collectionId: "****",
queries: [
Query.equal("user_phone_no", phoneNo),
Query.orderDesc('$createdAt'),
],
);
$createdAt show error, how can I query this, any help
Summary
Solution: The issue is with the syntax of the query for the `$createdAt` field. To fix it, you need to escape the dollar sign before `$createdAt` by using `'\$createdAt'`. Additionally, make sure you have created an index for the `$createdAt` field. If you're still facing errors, provide screenshots and more information about the error message. Remember to format your queries as an array.
safwan
Apr 1, 2023, 08:51
have you created an index?
showmore
Rank 1: Thread
Apr 1, 2023, 08:55
yes, its format error, it show me red
showmore
Rank 1: Thread
Apr 1, 2023, 09:23
No the problem is on Query.orderDesc('$createdAt') I tried Query.orderDesc('${createdAt}') flutter consider it as local variable but its from appwrite database ($id, $createdAt, $updatedAt) common fields
safwan
Apr 1, 2023, 09:54
queries should be passed as an array
showmore
Rank 1: Thread
Apr 1, 2023, 10:10
only flutter expert answer me pls queries: [ Query.equal("user_phone_no", phoneNo), Query.orderDesc('$createdAt'), ],
showmore
Rank 1: Thread
Apr 1, 2023, 10:11
$createdAt shows red error, format error
safwan
Apr 1, 2023, 10:33
what is the error you're getting. show screenshots
safwan
Apr 1, 2023, 10:35
also, show your indexes
Drake
Apr 1, 2023, 14:52
You need to escape the $ like:
Query.orderDesc('\$createdAt')
showmore
Rank 1: Thread
Apr 4, 2023, 07:34
Thanks Steven
Musicien
Aug 22, 2023, 00:54
I spent hours on this syntax issue until I read your response. Thanks so much!