package ru.forbion.f7cloud.core.database

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query

@Dao
interface FilesDao {
    @Query("SELECT * FROM files WHERE serverUrl = :serverUrl AND username = :username ORDER BY isDirectory DESC, name ASC")
    suspend fun list(serverUrl: String, username: String): List<FileEntity>

    @Query("DELETE FROM files WHERE serverUrl = :serverUrl AND username = :username")
    suspend fun clear(serverUrl: String, username: String)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(items: List<FileEntity>)
}
