Skip to content

Instantly share code, notes, and snippets.

@MarcoSignoretto
Created May 9, 2023 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcoSignoretto/095dea82fd27bdaca0577cab0a457284 to your computer and use it in GitHub Desktop.
Save MarcoSignoretto/095dea82fd27bdaca0577cab0a457284 to your computer and use it in GitHub Desktop.
override suspend fun insert(title: String, content: String) {
noteDao.notesQueries.transaction {
val maxPosition = noteDao.notesQueries.maxPosition().executeAsOneOrNull()?.MAX
val uid = UUID.randomUUID()
noteDao.notesQueries.insert(
uid = uid,
title = title,
content = content.safeEncodeToByteArray(),
isSecured = false.toLong(),
position = maxPosition?.plus(1) ?: 0,
passwordHash = byteArrayOf(1) // workaround for issue https://github.com/touchlab/SQLiter/issues/42
)
}
val notes = fetchNotes()
_stream.emit(notes)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment