package com.ar.paintar.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 ImageDataDao {
    @Insert
    void insertAll(List<ImageData> imageData);

    @Insert
    void insert(ImageData imageData);

    @Update
    void update(ImageData imageData);

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

    @Query("SELECT * FROM ImageData WHERE imagePath LIKE :category || '/%' AND imageType = 0 LIMIT 1")
    LiveData<List<ImageData>> getLiveFirstImageDataByCategory(String category);

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

    @Query("SELECT * FROM ImageData WHERE imageType = 1 ")
    LiveData<List<ImageData>> getLiveAllImportImageData();

    @Query("SELECT * FROM ImageData WHERE imageType = 1 ")
    List<ImageData> getAllImportImageData();

    @Query("SELECT * FROM ImageData WHERE favoriteStatus = 1 ")
    LiveData<List<ImageData>> getLiveAllFavoriteImageData();

}
