aboutsummaryrefslogblamecommitdiff
path: root/app/src/main/java/SubredditDatabase/SubredditDao.java
blob: ac291f9aafc42c309f9b881fbc0fbb6d59a39d22 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
                          














                                                        
                                                                 
                                                                            
 
                                                                         
                                                        
 
package SubredditDatabase;

import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;

@Dao
public interface SubredditDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(SubredditData SubredditData);

    @Query("DELETE FROM subreddits")
    void deleteAllSubreddits();

    @Query("SELECT * from subreddits WHERE name = :namePrefixed")
    LiveData<SubredditData> getSubredditLiveDataByName(String namePrefixed);

    @Query("SELECT * from subreddits WHERE name = :namePrefixed LIMIT 1")
    SubredditData getSubredditData(String namePrefixed);
}