5.5 Data Access Objects
Anatomy of a DAO
@Dao
interface GroceryItemDao {
// Get all GroceryItemEntitys
@Query("SELECT * FROM groceryitementity")
fun getAll(): List<GroceryItemEntity>
// Get all GroceryItemEntitys who's name is in the list `items`
@Query("SELECT * FROM groceryitementity WHERE item IN (:items)")
fun loadAllByIds(items: List<String>): List<GroceryItemEntity>
// Insert the given GroceryItemEntity
@Insert
fun insertAll(vararg users: GroceryItemEntity)
// Update the GroceryItemEntity given. Uses the primary key to match up the Entity
@Update
fun update(groceryItem: GroceryItemEntity)
// Delete the given GroceryItemEntity by the primary key
@Delete
fun delete(groceryItem: GroceryItemEntity)
}Last updated
Was this helpful?