package com.ar.ardrawingboard.room;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

@Dao
public interface BoardEntryDao {
    @Insert
    void insertAll(List<BoardEntry> boardEntry);

    @Insert
    void insert(BoardEntry boardEntry);

    @Update
    void update(BoardEntry boardEntry);

    @Query("SELECT * FROM board_entry WHERE path LIKE :path || '/%' AND type = 0")
    LiveData<List<BoardEntry>> getImageByPath(String path);

    @Query("SELECT * FROM board_entry WHERE path LIKE :path || '/%' AND type = 0 LIMIT 1")
    LiveData<List<BoardEntry>> getImageByPathLimitOne(String path);

    @Query("SELECT * FROM board_entry WHERE type = 1 ")
    LiveData<List<BoardEntry>> getImportLive();

    @Query("SELECT * FROM board_entry WHERE type = 1 ")
    List<BoardEntry> getImport();

    @Query("SELECT * FROM board_entry WHERE isFavorite = 1 ")
    LiveData<List<BoardEntry>> getFavorite();
}
