implement a method to delete Place entity from database

This commit is contained in:
Christo Joby Antony 2024-10-18 01:07:22 +11:00
parent 46f60e5643
commit 5985e9ad9c
3 changed files with 20 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package fr.free.nrw.commons.nearby; package fr.free.nrw.commons.nearby;
import androidx.room.Dao; import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert; import androidx.room.Insert;
import androidx.room.OnConflictStrategy; import androidx.room.OnConflictStrategy;
import androidx.room.Query; import androidx.room.Query;
@ -24,6 +25,12 @@ public abstract class PlaceDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
public abstract void saveSynchronous(Place place); public abstract void saveSynchronous(Place place);
/**
* Deletes a Place object from the database
* based on the provided entity.
*/
@Delete
public abstract void deletePlace(Place place);
/** /**
* Retrieves a Place object from the database based on the provided entity ID. * Retrieves a Place object from the database based on the provided entity ID.
* *

View file

@ -36,4 +36,11 @@ public class PlacesLocalDataSource {
public Completable savePlace(Place place) { public Completable savePlace(Place place) {
return placeDao.save(place); return placeDao.save(place);
} }
/**
* Deletes a Place object from the database
* based on the provided entity.
*/
public void deletePlace(final Place place) {placeDao.deletePlace(place);}
} }

View file

@ -38,4 +38,10 @@ public class PlacesRepository {
return localDataSource.fetchPlace(entityID); return localDataSource.fetchPlace(entityID);
} }
/**
* Deletes a Place object from the database
* based on the provided entity.
*/
public void deletePlace(final Place place){ localDataSource.deletePlace(place);}
} }