如何在Android房间中使用his属性的条件从sqlite数据库中删除对象

如何在Android房间中使用his属性的条件从sqlite数据库中删除对象,android,sqlite,kotlin,android-sqlite,android-room,Android,Sqlite,Kotlin,Android Sqlite,Android Room,如果属性lessonId与我的db中的一个对象匹配,我想从我的SQLite数据库中删除一行(对象)。 我正在使用房间 我不知道该提出哪一个问题 通知道: @Dao interface NotificationDao { @Query("SELECT * FROM notifications") fun getNotifications(): Single<List<Notification>> @Insert(onConfli

如果属性
lessonId
与我的
db
中的一个对象匹配,我想从我的
SQLite数据库中删除一行(对象)。
我正在使用
房间

我不知道该提出哪一个问题

通知道:

@Dao
interface NotificationDao {
    @Query("SELECT * FROM notifications")
    fun getNotifications(): Single<List<Notification>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun updateNotification(notification: Notification): Completable

    @Query("DELETE")
    fun clearNotification(notification: Notification): Completable
}

您是否尝试使用条件删除(但必须更改参数的类型)


事实上,我昨天找到了这个答案:
@Entity(tableName = "notifications")
data class Notification(
        @PrimaryKey
        var lessonId: String = "",
        var count: Int = 0)
@Query("DELETE FROM notifications WHERE lessonId = :lessonId")
fun clearNotification(lessonId: String): Completable