CampsiteRepository

class CampsiteRepository(enableListener: Boolean = true)

Manages campsite storage, retrieval, and filtering in Firestore.

Parameters

enableListener

Whether to listen for live database updates.

Constructors

Link copied to clipboard
constructor(enableListener: Boolean = true)

Properties

Link copied to clipboard

Cached campsite listings.

Link copied to clipboard

Campsites matching the applied filters.

Link copied to clipboard

The latest filter error, or null.

Link copied to clipboard

Whether Explore filtering is enabled.

Link copied to clipboard

Whether a filter request is running.

Functions

Link copied to clipboard
suspend fun addCampsite(campsite: Campsite)

Adds a new campsite to the Firestore database.

Link copied to clipboard

Clears all applied campsite filters and resets the filtering state.

Link copied to clipboard
fun close()

Removes the Firestore snapshot listener.

Link copied to clipboard
suspend fun deleteCampsite(campsite: Campsite)

Deletes a campsite from the Firestore database.

Link copied to clipboard
suspend fun filterCampsites(startDate: Timestamp?, endDate: Timestamp?, location: String, minGuests: Int, maxGuests: Int, minRating: Double?)

Filters campsites based on dates, location, guest capacity, and rating.

Link copied to clipboard
fun get(campsiteId: String): Campsite?

Gets a Campsite object from the database given its campsiteId.

Link copied to clipboard

Gets all Campsite of a specific CampsiteOwner.

Link copied to clipboard
suspend fun updateCampsite(updatedCampsite: Campsite)

Overwrites an existing campsite in the Firestore database with updated data.