package com.ar.imagetracear.database;

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 ImageTraceEntryDao {
    @Insert
    void insertAll(List<ImageTraceEntry> imageTraceEntry);

    @Insert
    void insert(ImageTraceEntry imageTraceEntry);

    @Update
    void update(ImageTraceEntry imageTraceEntry);

    @Query("SELECT * FROM imageTrace_entry WHERE path LIKE :path || '/%' AND type = 0 ORDER BY id DESC")
    LiveData<List<ImageTraceEntry>> getFileByPath(String path);

    @Query("SELECT * FROM imageTrace_entry WHERE path LIKE :path || '/%' AND type = 0 ORDER BY id DESC LIMIT 1")
    LiveData<List<ImageTraceEntry>> getFileByPathLimitOne(String path);

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

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

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