Skip to content

Commit

Permalink
[player-database]
Browse files Browse the repository at this point in the history
+ 修复了列查询的BUG
  • Loading branch information
FxRayHughes committed Aug 1, 2024
1 parent 4860e16 commit 86ff464
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Database(val type: Type, val dataSource: DataSource = type.host().createDa
// 查询某个User的Key对应的Value
fun select(user: String, key: String): String? {
return type.tableVar().select(dataSource) {
rows("key", "value")
rows("value")
where("user" eq user and ("key" eq key))
}.firstOrNull {
getString("value")
Expand All @@ -57,13 +57,22 @@ class Database(val type: Type, val dataSource: DataSource = type.host().createDa
// return: Map<user, value>
fun getList(name: String): MutableMap<String, String> {
return type.tableVar().select(dataSource) {
rows("value")
rows("user", "value")
where("key" eq name)
}.map {
getString("user") to getString("value")
}.toMap(ConcurrentHashMap())
}

fun getList(name: String, value: String): List<String> {
return type.tableVar().select(dataSource) {
rows("user")
where("key" eq name and ("value" eq value))
}.map {
getString("user")
}
}

fun remove(user: String, name: String) {
type.tableVar().delete(dataSource) {
where("user" eq user and ("key" eq name))
Expand Down

0 comments on commit 86ff464

Please sign in to comment.