package com.ar.artraceartpro.data.local.dao;

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

import com.ar.artraceartpro.data.local.entity.ImageData;

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>> getAllCategory(String category);

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

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

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

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

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

}
