fetchMothers function
Fetches mothers from the database with optional date filtering.
Queries the Appwrite database for documents of type 'mother'.
Optionally filters by fromDate
and tillDate
if provided.
Implementation
Future<List<models.Document>> fetchMothers(
Databases db, {
DateTime? fromDate,
DateTime? tillDate,
}) async {
// Implementation would depend on your actual query logic
// This is a placeholder based on the original code
List<String> queries = [];
queries.add(Query.equal('type', 'mother'));
if (fromDate != null) {
queries.add(
Query.greaterThanEqual('createdAt', fromDate.toIso8601String()),
);
}
if (tillDate != null) {
queries.add(Query.lessThanEqual('createdAt', tillDate.toIso8601String()));
}
final result = await db.listDocuments(
databaseId: AppConstants.appwriteDatabaseId, // Replace with actual DB ID
collectionId:
AppConstants.userCollectionId, // Replace with actual collection ID
queries: queries,
);
return result.documents;
}