Overview
ThePhraseRepository class handles CRUD operations for user phrases stored in Firebase Firestore. Each user’s phrases are stored in a subcollection under their user document.
Class Definition
Firestore database instance for storing and retrieving phrases
Firebase Authentication instance to get the current user ID
Private Methods
uid
Retrieves the current user’s ID.This method throws
IllegalStateException if no user is currently authenticated.col
Returns a reference to the current user’s phrases collection.users/{uid}/phrases
Public Methods
add
Adds a new phrase to the current user’s collection.The phrase text to save
The method automatically sets the
createdAt timestamp to the current system time in milliseconds.get
Retrieves all phrases for the current user, ordered by creation date (newest first).A list of all user phrases, ordered by creation date in descending order
update
Updates the text of an existing phrase.The unique identifier of the phrase to update
The new text for the phrase
delete
Deletes a phrase from the user’s collection.The unique identifier of the phrase to delete
Error Handling
All methods may throw
IllegalStateException with the message “No hay sesión activa” (No active session) if called when no user is authenticated.Firestore Structure
Phrases are stored with the following structure:Source Location
com.demodogo.ev_sum_2.data.repositories.PhraseRepository