Handle errors while querying notes
This commit is contained in:
parent
c1fabe943c
commit
86ec7f4de8
@ -6,14 +6,15 @@ import java.sql.PreparedStatement
|
||||
import java.sql.ResultSet
|
||||
import java.sql.Types
|
||||
import java.util.*
|
||||
import java.util.UUID as JavaUUID
|
||||
|
||||
class UuidBinarySqlType : SqlType<java.util.UUID>(Types.BINARY, typeName = "uuidBinary") {
|
||||
override fun doGetResult(rs: ResultSet, index: Int): UUID? {
|
||||
class UuidBinarySqlType : SqlType<JavaUUID>(Types.BINARY, typeName = "uuidBinary") {
|
||||
override fun doGetResult(rs: ResultSet, index: Int): JavaUUID? {
|
||||
val value = rs.getBytes(index) ?: return null
|
||||
return ByteBuffer.wrap(value).let { b -> UUID(b.long, b.long) }
|
||||
return ByteBuffer.wrap(value).let { b -> JavaUUID(b.long, b.long) }
|
||||
}
|
||||
|
||||
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: UUID) {
|
||||
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: JavaUUID) {
|
||||
val bytes = ByteBuffer.allocate(16)
|
||||
.putLong(parameter.mostSignificantBits)
|
||||
.putLong(parameter.leastSignificantBits)
|
||||
@ -22,6 +23,6 @@ class UuidBinarySqlType : SqlType<java.util.UUID>(Types.BINARY, typeName = "uuid
|
||||
}
|
||||
}
|
||||
|
||||
fun <E : Any> BaseTable<E>.uuidBinary(name: String): BaseTable<E>.ColumnRegistration<java.util.UUID> {
|
||||
fun <E : Any> BaseTable<E>.uuidBinary(name: String): BaseTable<E>.ColumnRegistration<JavaUUID> {
|
||||
return registerColumn(name, UuidBinarySqlType())
|
||||
}
|
||||
|
||||
@ -74,14 +74,22 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async loadNotes() {
|
||||
await this.$axios.get('/notes').then((e) => {
|
||||
await this.$axios
|
||||
.get('/notes')
|
||||
.then((e) => {
|
||||
this.notes = e.data
|
||||
this.loading = false
|
||||
})
|
||||
.catch((_) => {})
|
||||
},
|
||||
editItem(item) {},
|
||||
async deleteItem(item) {
|
||||
await this.$axios.delete(`/notes/${item.uuid}`).then(this.loadNotes)
|
||||
try {
|
||||
await this.$axios.delete(`/notes/${item.uuid}`)
|
||||
} catch (_) {
|
||||
} finally {
|
||||
await this.loadNotes()
|
||||
}
|
||||
},
|
||||
format,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user