[ADD] update and insert coupon
This commit is contained in:
@@ -22,6 +22,9 @@ public interface CouponDao {
|
||||
@Query("SELECT * FROM coupon")
|
||||
LiveData<List<Coupon>> selectAll();
|
||||
|
||||
@Update
|
||||
public void update(Coupon coupon);
|
||||
|
||||
/*
|
||||
to add an observer to the livedata, you can use the example from https://medium.com/mindorks/using-room-database-with-livedata-android-jetpack-cbf89b677b47
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,14 @@ public class CouponRepository {
|
||||
mAllCoupons = mCouponDao.selectAll();
|
||||
}
|
||||
|
||||
public void insert(Coupon... coupons) {
|
||||
mCouponDao.insertAll(coupons);
|
||||
}
|
||||
|
||||
public void update(Coupon coupon) {
|
||||
mCouponDao.update(coupon);
|
||||
}
|
||||
|
||||
public LiveData<List<Coupon>> getAllCoupons() {
|
||||
return mAllCoupons;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user