Hi! Is there a way to dynamically build the listDocuments query? In the app, the "base" query I have is
Query.equal('category', 'expenses'),
Query.greaterThan('amount', 100),
];
final response = await databases.listDocuments(
'<DATABASE_ID>',
'<COLLECTION_ID>',
query,
);
I would like to have a checkbox (or a switch) for a select date and then have this date added to the query parameters. How should I do it?
TIA
What about adding/removing the Query for the date to the base query list on checkbox toggle?
Yes, that's my idea, but how to I add/remove to the query list? What type is Query.equal('date',<date>)?
How about just doing
//checkbox enabled
query.add(Query.equal('category', 'expenses')); //This will be the new query to add
//checkbox disabled
query.removeLast();
This method will require a bit of checks to make sure you're not removing any of the base queries. You could use a map for the queries and remove by the query's key. Example
// Query.method() generates Strings
final Map<String, String> query = {
'category': Query.equal('category', 'expenses'),
'amount': Query.greaterThan('amount', 100),
};
//checkbox toggle on
query.addAll({
'date': Query.equal('date', ['2024-2-15'])
});
//checkbox toggle off
query.remove('date');
//To get queries
query.values.toList();
Recommended threads
- listRows result parsing issue
I'm using Appwrite Dart SDK "24.2.0". When I perform a listRows call in dart, I have this reponse in JSON: in " Future<models.RowList> listRows()" { "total" :...
- Broken Flutter SDK >=24.1.0
Row.fromMap now does: ``` data: Map<String, dynamic>.from(map["data"] ?? {}) ``` But Appwrite Cloud TablesDB row responses return custom row columns flattene...
- Flutter OAuth2 does not attach Google se...
Hi Appwrite team, I’m using Appwrite Auth in a Flutter mobile app and trying to upgrade an anonymous user to Google OAuth. Docs say that if there is already a...