aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/SubredditDatabase/SubredditDao.java
blob: b99b8bafbdce25a5a2f4f5431d28753f96f27623 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package SubredditDatabase;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.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 COLLATE NOCASE LIMIT 1")
    LiveData<SubredditData> getSubredditLiveDataByName(String namePrefixed);

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