-
-
Save MarcoSignoretto/095dea82fd27bdaca0577cab0a457284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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