package com.example.myapplication.DataBase;


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

import com.example.myapplication.model.AudioEntity;

import java.util.List;

@Dao
public interface AudioDao {
    @Insert
    void insert(AudioEntity audioEntity);

    @Update
    void update(AudioEntity audioEntity);

    @Delete
    void delete(AudioEntity audioEntity);

    @Query("SELECT * FROM audio_entities ORDER BY createdAt DESC")
    List<AudioEntity> getAllAudios();

    @Query("SELECT * FROM audio_entities WHERE id = :id")
    AudioEntity getAudioById(int id);

    @Query("SELECT * FROM audio_entities WHERE AudioPath = :path")
    AudioEntity getAudioByPath(String path);

    @Query("DELETE FROM audio_entities WHERE AudioPath = :path")
    void deleteByPath(String path);

}