Fork me on GitHub
#xtdb
<
2022-04-17
>
Nundrum22:04:16

#{[{"name":"beta","host":"vermouth","links":[],"size":8888,"oldest":"Thu Dec 31 19:00:00 EST 2020","newest":"Thu Mar 31 20:00:00 EDT 2022","description":"the Beta test node","id":"vermouth-beta"}],
[{"name":"alpha","host":"vermouth","links":[],"size":8888,"oldest":"Thu Dec 31 19:00:00 EST 2020","newest":"Thu Mar 31 20:00:00 EDT 2022","description":"the Alpha test node","id":"vermouth-alpha"}]}
Why is the response to a query made of a set of vectors, each vector containing one map? I get the set, but not why each vector contains only one map.

refset23:04:27

The vector corresponds with your definition of :find

Nundrum23:04:59

So I have (pull p1 [*]) and the extra vector comes from that. 💡 Thanks again 🙂

🙏 1
Nundrum23:04:08

Hrm no taking out that vector didn't get rid of it.

Nundrum23:04:04

(into [] (xt/q (xt/db node)           
        '{:find  [(pull p1 [*]) ]       
          :where [[p1 :lochmess/host h]]
          :in [h]}                      
        hostname))                      
Is there some way to rewrite that to get rid of the extra vector?

emccue04:04:49

(into [] 
       (mapcat identity
         (xt/q (xt/db node)           
          '{:find  [(pull p1 [*]) ]       
            :where [[p1 :lochmess/host h]]
            :in [h]}                      
        hostname))    

✔️ 1
Nundrum12:04:37

That's what I've been doing. It just felt like the wrong approach. Thanks!

nivekuil19:04:54

(mapv peek res) is the way to do it. shorter and much faster

notbad 1
Nundrum19:04:52

Peek! That's new to me. Thank you!

nivekuil19:04:26

np -- one of the unfortunate things about clojure is how the performant way and the intuitive way often differ. vectors really like to be peeked

🙂 1