package com.ar.arsketch.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 ImageEntryDao {
    @Insert
    void insertAll(List<ImageEntry> imageEntry);

    @Insert
    void insert(ImageEntry imageEntry);

    @Update
    void update(ImageEntry imageEntry);

    @Query("SELECT * FROM image_entry WHERE imagePath LIKE :category || '/%' AND imageType = 0")
    LiveData<List<ImageEntry>> getImagesByCategoryLive(String category);

    @Query("SELECT * FROM image_entry WHERE imagePath LIKE :category || '/%' AND imageType = 0 LIMIT 1 OFFSET :index")
    LiveData<List<ImageEntry>> getImageByCategoryAndIndexLive(String category, int index);

    @Query("SELECT * FROM image_entry WHERE imageType = 1 ")
    LiveData<List<ImageEntry>> getAllImportImageLive();

    @Query("SELECT * FROM image_entry WHERE imageType = 1 ")
    List<ImageEntry> getAllImportImage();

    @Query("SELECT * FROM image_entry WHERE favoriteStatus = 1 ")
    LiveData<List<ImageEntry>> getAllFavoriteLive();

}
