package org.pixeldroid.app.utils.db.dao.feedContent.posts

import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Query
import org.pixeldroid.app.utils.db.dao.feedContent.FeedContentDao
import org.pixeldroid.app.utils.db.entities.PublicFeedStatusDatabaseEntity

@Dao
interface PublicPostDao: FeedContentDao<PublicFeedStatusDatabaseEntity> {
    @Query("""SELECT * FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri 
            ORDER BY datetime(created_at) DESC""")
    override fun feedContent(userId: String, instanceUri: String): PagingSource<Int, PublicFeedStatusDatabaseEntity>

    @Query("DELETE FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri")
    override suspend fun clearFeedContent(userId: String, instanceUri: String)

    @Query("DELETE FROM publicPosts WHERE user_id=:userId AND instance_uri=:instanceUri AND id=:id")
    override suspend fun delete(id: String, userId: String, instanceUri: String)

}