Firestore, also known as Firebase Firestore, is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform. It's designed to store and sync data for client- and server-side development. Firestore can be integrated into Android applications to provide real-time data synchronization, offline support, and efficient querying capabilities.
This is content of RequestModel and ResponseModel:
dataclassFirestoreRequest(var id: String? =emptyString(),var image: String? =emptyString(),val name: String? =emptyString(),val age: Int? =null,val address: String? =emptyString()){@ExcludefuntoMap() =hashMapOf<String, Any?>("id" to id,"name" to name,"age" to age,"address" to address,"image" to image )}
The FirestoreRequest class is a data model for holding information typically stored in a Firestore document. The toMap function provides a convenient way to convert the object's properties into a format suitable for Firestore operations. The @Exclude annotation ensures that the toMap function itself is not serialized when the object is converted to a Firestore document.
The FirestoreResponse data class is a Kotlin model representing a response from a Firestore database. It contains five nullable properties: id (a string for the document ID), name (a string for the name of the person or item), age (an integer for the age), address (a string for the address), and image (a string for the image URL or path). Each property is initialized to null by default, making it optional when creating instances of this class. This model can be used to map Firestore documents to Kotlin objects, facilitating data retrieval and manipulation within an application.