是否可以将 Flow 与 Room 删除或插入操作一起使用,因为它在 RxJava 中使用 Single 或 Maybe that returns row ids?

Is it possible to use Flow with Room delete or insert operations as it's used in RxJava with Single or Maybe that returns row ids?

通话中

@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(entity: PostEntity): Flow<Long>
   
@Delete
fun deletePost(entity: PostEntity): Flow<Long>

returns编译错误

 Not sure how to handle insert method's return type.
    public abstract kotlinx.coroutines.flow.Flow<java.util.List<java.lang.Long>> insertFlow(@org.jetbrains.annotations.NotNull()

不能像在 RxJava 中那样使用带有 Int 或 long 的 Flow 来获取数据库操作结果的 ID 吗?

@Insert(onConflict = REPLACE)
fun insert(entity: T): Maybe<Long>

@Insert(onConflict = REPLACE)
fun insert(entity: T): Single<Long>

根据 Async queries with Kotlin coroutines in Room,Kotlin 协程中 MaybeSingle 的等价物是 suspend:

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insert(entity: PostEntity): Long

@Delete
suspend fun deletePost(entity: PostEntity): Long