package com.prank.funnypranksounds.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.prank.funnypranksounds.data.local.entity.AudioData;

import java.util.List;

@Dao
public interface AudioDataDao {

    @Insert
    void insertAll(List<AudioData> audioDataList);

    @Update
    void update(AudioData audioData);

    @Query("SELECT * FROM AudioData WHERE id IN (SELECT MIN(id) FROM AudioData GROUP BY categoryName)")
    LiveData<List<AudioData>> getFirstCategory();

    @Query("SELECT * FROM AudioData WHERE categoryName = :name")
    LiveData<List<AudioData>> getCategory(String name);

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