Krishanu singhOriginal post
Rank 1: Thread
''' suspend fun currentAffairs(date: String): Resource<List> {
return withContext(Dispatchers.IO) {
try {
val affairs = arrayListOf()
val response = database.listDocuments(
databaseId = appwriteConstants.DATABASE_ID,
collectionId = appwriteConstants.CURRENT_AFFAIRS_COLLECTION_ID,
queries = listOf(
Query.limit(limitMax),
Query.equal("\$createdAt", date)
)
).documents
response.forEach {
affairs.add(CurrentAffairsData.fromMap(it.data, it.id, it.createdAt))
}
Resource.Success(affairs)
} catch (e: Exception) {
Resource.Error(e.message ?: "An error occurred")
}
}
}'''
Summary
Developers are requesting assistance with fetching data based on a specific date in their currentAffairs function. They are attempting to query the database for documents created on a particular date but are not getting the desired results.