mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-04 06:33:11 +00:00
query fixes
This commit is contained in:
parent
77173a5fac
commit
a16cdaab29
@ -36,7 +36,7 @@ type
|
|||||||
|
|
||||||
proc dbQuery*[K](
|
proc dbQuery*[K](
|
||||||
key: K,
|
key: K,
|
||||||
value = true,
|
value = false,
|
||||||
sort = SortOrder.Ascending,
|
sort = SortOrder.Ascending,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
limit = -1
|
limit = -1
|
||||||
|
|||||||
@ -37,7 +37,7 @@ proc new*(T: type QueryIter, dispose = defaultDispose): T =
|
|||||||
|
|
||||||
proc init*(T: type Query,
|
proc init*(T: type Query,
|
||||||
key: Key,
|
key: Key,
|
||||||
value = true,
|
value = false,
|
||||||
sort = SortOrder.Ascending,
|
sort = SortOrder.Ascending,
|
||||||
offset = 0,
|
offset = 0,
|
||||||
limit = -1): Query =
|
limit = -1): Query =
|
||||||
|
|||||||
@ -126,7 +126,7 @@ suite "queryTests":
|
|||||||
|
|
||||||
test "Key should query all keys and all it's children":
|
test "Key should query all keys and all it's children":
|
||||||
let
|
let
|
||||||
q = dbQuery(key: key1, value: true)
|
q = dbQuery(key=key1, value=true)
|
||||||
|
|
||||||
ds.put(key1, val1).tryGet
|
ds.put(key1, val1).tryGet
|
||||||
ds.put(key2, val2).tryGet
|
ds.put(key2, val2).tryGet
|
||||||
@ -149,7 +149,7 @@ suite "queryTests":
|
|||||||
|
|
||||||
test "query should cancel":
|
test "query should cancel":
|
||||||
let
|
let
|
||||||
q = dbQuery(key: key1, value: true)
|
q = dbQuery(key= key1, value= true)
|
||||||
|
|
||||||
ds.put(key1, val1).tryGet
|
ds.put(key1, val1).tryGet
|
||||||
ds.put(key2, val2).tryGet
|
ds.put(key2, val2).tryGet
|
||||||
@ -179,7 +179,7 @@ suite "queryTests":
|
|||||||
|
|
||||||
test "Key should query all keys without values":
|
test "Key should query all keys without values":
|
||||||
let
|
let
|
||||||
q = dbQuery(key: key1, value: false)
|
q = dbQuery(key= key1, value= false)
|
||||||
|
|
||||||
ds.put(key1, val1).tryGet
|
ds.put(key1, val1).tryGet
|
||||||
ds.put(key2, val2).tryGet
|
ds.put(key2, val2).tryGet
|
||||||
@ -204,7 +204,7 @@ suite "queryTests":
|
|||||||
|
|
||||||
test "Key should not query parent":
|
test "Key should not query parent":
|
||||||
let
|
let
|
||||||
q = dbQuery(key: key2, value: true)
|
q = dbQuery(key= key2, value= true)
|
||||||
|
|
||||||
ds.put(key1, val1).tryGet
|
ds.put(key1, val1).tryGet
|
||||||
ds.put(key2, val2).tryGet
|
ds.put(key2, val2).tryGet
|
||||||
@ -226,7 +226,7 @@ suite "queryTests":
|
|||||||
test "Key should all list all keys at the same level":
|
test "Key should all list all keys at the same level":
|
||||||
let
|
let
|
||||||
queryKey = Key.init("/a").tryGet
|
queryKey = Key.init("/a").tryGet
|
||||||
q = dbQuery(key: key1, value: true)
|
q = dbQuery(key= key1, value= true)
|
||||||
|
|
||||||
ds.put(key1, val1).tryGet
|
ds.put(key1, val1).tryGet
|
||||||
ds.put(key2, val2).tryGet
|
ds.put(key2, val2).tryGet
|
||||||
@ -253,7 +253,7 @@ suite "queryTests":
|
|||||||
test "Should apply limit":
|
test "Should apply limit":
|
||||||
let
|
let
|
||||||
key = Key.init("/a").tryGet
|
key = Key.init("/a").tryGet
|
||||||
q = dbQuery(key: key1, limit: 10, value: false)
|
q = dbQuery(key= key1, limit= 10, value= false)
|
||||||
|
|
||||||
for i in 0..<100:
|
for i in 0..<100:
|
||||||
let
|
let
|
||||||
@ -274,7 +274,7 @@ suite "queryTests":
|
|||||||
let
|
let
|
||||||
key = Key.init("/a").tryGet
|
key = Key.init("/a").tryGet
|
||||||
keyId = KeyId.new $key
|
keyId = KeyId.new $key
|
||||||
q = dbQuery(key: keyId, offset: 90)
|
q = dbQuery(key= keyId, offset= 90)
|
||||||
|
|
||||||
for i in 0..<100:
|
for i in 0..<100:
|
||||||
let
|
let
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user