2
votes

I am using Clojure and congomongo to interact with mongodb.

I have a document in a collection test with the following structure -

{:_id #<ObjectId 50e8a4de2b5e29d6f4ab3d66>, :fields {:project {:key "test"}}}

and want to query based on the embedded document field :key

when I run the following -

(fetch :test {:fields {:project {:key "test"}}})

I get the error -

"IllegalArgumentException No value supplied for key: {:fields {:project {:key "test"}}} clojure.lang.PersistentHashMap.createWithCheck (PersistentHashMap.java:89)"

if I run the following from tha mongodb console, the correct document is returned -

db.test.find({"fields" : {"project" : {"key" : "test"}}})

Thanks for any advice

1
Fix the formatting of your code. - Andreas Jung

1 Answers

1
votes

Looks like you're just missing the :where keyword

(fetch :test :where {:fields {:project {:key "test"}}})