mirror of
https://github.com/nushell/nushell.git
synced 2025-06-05 17:46:44 +02:00
std-rfc/kv: optimize kv get by only selecting one row from the stor db (#15792)
Optimize std-rfc/kv, kv get to only read one row from the sqlite db.
This commit is contained in:
parent
7c50f7c714
commit
88d421dcb6
@ -111,16 +111,12 @@ export def "kv get" [
|
||||
] {
|
||||
let db_open = (db_setup --universal=$universal)
|
||||
do $db_open
|
||||
# Hack to turn a SQLiteDatabase into a table
|
||||
| $in.std_kv_store | wrap temp | get temp
|
||||
| where key == $key
|
||||
# Should only be one occurrence of each key in the stor
|
||||
| get -i value.0
|
||||
| query db "SELECT value FROM std_kv_store WHERE key = :key" --params { key: $key }
|
||||
| match $in {
|
||||
# Key not found
|
||||
null => null
|
||||
# Key found
|
||||
_ => { from nuon }
|
||||
# Match should be exactly one row
|
||||
[$el] => { $el.value | from nuon }
|
||||
# Otherwise no match
|
||||
_ => null
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user