On Feb 28, 2014, at 9:08 AM, xavi <[email protected]> wrote: > (monger.collection/find "products" { :price_in_subunits { "gt" 1200 "lte" > 4000 } })
And you could use $gt, $lte directly if you require/refer Monger's operators
namespace:
(monger.multi.collection/find db :products {:price_in_subunits {$gt 1200 $lte
4000}})
Note that Monger seems to accept keywords for collection names, even tho' they
are type-hinted as ^String, because it calls `name` on collection before
passing it to MongoDB's driver (so I'm not sure why the ^String hint is even
there?).
> (somnium.congomongo/fetch :products :where { :price_in_subunits { :$gt 1200
> :$lte 4000 } })
Michael pointed out to me that :$gt is not sanctioned by Clojure's definition
of keywords (even tho' it currently "works").
> db.products.find( { price_in_subunits: { $gt: 1200 $lte: 4000 } )
Yes, the fetch vs find aspect of CongoMongo has always bothered me too and I
don't understand the various deviations from the MongoDB API / shell syntax.
Some are subtle and confusing (IMO), but it's what I'm used to now... :)
> Good to know that the DSL in Monger is completely optional.
I like the DSL:
(with-collection coll
(find {:_id id})
(limit 1)
(options {:slaveok slave-ok?})
(keywordize-fields true)))
although we have to jump through some hoops with coll to support multiple
databases (dropping down to the Java API to get a Collection object from a
specific DB object).
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)
signature.asc
Description: Message signed with OpenPGP using GPGMail
