package com.example.jetpackdb.data.local

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import kotlinx.coroutines.flow.Flow

@Dao
interface MyNoteDao {

	@Query("SELECT * from ${MyNoteEntity.TABLE_NAME}")
	fun getall(): Flow<List<MyNoteEntity>>

	@Insert(onConflict = OnConflictStrategy.ABORT)
	suspend fun insert(item: MyNoteEntity)

	@Query("SELECT * FROM ${MyNoteEntity.TABLE_NAME} WHERE ${MyNoteEntity.TABLE_NAME}.${MyNoteEntity.ID} == :id")
	fun get(id: Long): Flow<MyNoteEntity>

	@Update
	suspend fun update(vararg items: MyNoteEntity)

	@Delete
	suspend fun delete(vararg items: MyNoteEntity)
}