mirror of
https://github.com/nushell/nushell.git
synced 2025-06-07 02:26:52 +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)
|
let db_open = (db_setup --universal=$universal)
|
||||||
do $db_open
|
do $db_open
|
||||||
# Hack to turn a SQLiteDatabase into a table
|
| query db "SELECT value FROM std_kv_store WHERE key = :key" --params { key: $key }
|
||||||
| $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
|
|
||||||
| match $in {
|
| match $in {
|
||||||
# Key not found
|
# Match should be exactly one row
|
||||||
null => null
|
[$el] => { $el.value | from nuon }
|
||||||
# Key found
|
# Otherwise no match
|
||||||
_ => { from nuon }
|
_ => null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user