Back

Please help me for set the query, I want to fetch data according to any date

  • 0
  • Android
Krishanu singh
2 Jul, 2024, 15:49

''' suspend fun currentAffairs(date: String): Resource<List<CurrentAffairsData>> { return withContext(Dispatchers.IO) { try { val affairs = arrayListOf<CurrentAffairsData>()

TypeScript
            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")
        }
    }
}'''
TL;DR
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.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more