Delete CRUD operation

The delete operation will remove the existing data from the database. What follows is its implementation:

    val NOTE = object : Crud<Note> { 
      ... 
      override fun delete(what: Note): Int = delete(listOf(what)) 
         override fun delete(what: Collection<Note>): Int { 
         val db = DbHelper(name, version).writableDatabase 
         db.beginTransaction() 
         val ids = StringBuilder() 
         what.forEachIndexed { index, item -> 
         ids.append(item.id.toString()) 
           if (index < what.size - 1) { 
              ids.append(", ") 
           } 
         } 
         val table = DbHelper.TABLE_NOTES 
         val statement = db.compileStatement( 
           "DELETE FROM $table WHERE ${DbHelper.ID} IN ($ids);" 
         ) 
         val count = statement.executeUpdateDelete() 
         val success = count > 0 
         if (success) { 
           db.setTransactionSuccessful() 
           Log.i(tag, "Delete [ SUCCESS ][ $count ][ $statement ]") 
         } else { 
            Log.w(tag, "Delete [ FAILED ][ $statement ]") 
         } 
          db.endTransaction() 
          db.close() 
          return count 
        } 
        ... 
     } 
     ... 
     val TODO = object : Crud<Todo> { 
       ... 
       override fun delete(what: Todo): Int = delete(listOf(what)) 
       override fun delete(what: Collection<Todo>): Int { 
         val db = DbHelper(name, version).writableDatabase 
         db.beginTransaction() 
         val ids = StringBuilder() 
         what.forEachIndexed { index, item -> 
         ids.append(item.id.toString()) 
            if (index < what.size - 1) { 
                ids.append(", ") 
            } 
        } 
        val table = DbHelper.TABLE_TODOS 
        val statement = db.compileStatement( 
          "DELETE FROM $table WHERE ${DbHelper.ID} IN ($ids);" 
        ) 
        val count = statement.executeUpdateDelete() 
        val success = count > 0 
        if (success) { 
           db.setTransactionSuccessful() 
           Log.i(tag, "Delete [ SUCCESS ][ $count ][ $statement ]") 
        } else { 
           Log.w(tag, "Delete [ FAILED ][ $statement ]") 
        } 
         db.endTransaction() 
         db.close() 
         return count 
        } 
        ... 
    } 
    ...