KQLite DELETE
Quickly deleting data
// DELETE FROM Artists WHERE ArtistId = ?;
Artists.quickDelete { it: Artists
it.artistId.EQ(3)
}
Content copied to clipboard
Delete all rows without WHERE
// DELETE FROM Artists;
Artists.quickDelete(where = null)
Content copied to clipboard
Delete execute
// DELETE FROM artists WHERE Name LIKE ? LIMIT ?;
Artists
.delete()
.where { it: Artists
it.artistName LIKE "%Cool%"
}
.limit(2)
.execute()
Content copied to clipboard
Delete RETURNING
// DELETE FROM artists WHERE ArtistId > ?
// ORDER BY ArtistId DESC LIMIT ?
// RETURNING ArtistId;
val cursor = Artists
.delete()
.where { it: Artists
it.artistId GT 1
}
.orderBy(Artists.artistId, Sort.DESC)
.limit(3)
.executeReturning(Artists.artistId)
val deleted = cursor
.asSequence()
.map { it[Artists.artistId] }
.toList()
println("Artists deleted: ${deleted.joinToString()}")
cursor.close()
Content copied to clipboard