On 13 October 2014 at 19:55:37, Ahmad Hammad (
ah...@buttercloud.com) wrote:
> > I this function works without the :return-new map, however
> with it I get ""No value supplied for key: {:return-new true}":
>
> (defn get-next-sequence [project-key]
> (mc/find-and-modify "projects"
> {:key project-key}
> {$inc {:seq 1}}
> {:return-new true}))
>
>
>
> java.lang.IllegalArgumentException: No value supplied for
> key: {:return-new true} PersistentHashMap.java:77 clojure.lang.PersistentHashMap.create
> collection.clj:230 monger.collection/find-and-modify
> RestFn.java:467 clojure.lang.RestFn.invoke
>
> based on this (
https://github.com/michaelklishin/monger/blob/ef539f48c8c6a880c7c4e0ced2eff7d4631a0cb6/test/monger/test/atomic_modifiers_test.clj#L413)
> the syntax looks correct.
All monger.collection functions require a connection object to be passed to them as of 2.0:
https://github.com/michaelklishin/monger/blob/master/ChangeLog.md#changes-between-180-and-200
you are not passing it.
> Another question, the $inc is updating the attribute with a java
> "NumberLong(1)", why doesn't it just use the number itself?
Monger does not modify numerical types. Number literals are longs (or doubles) in Clojure.
What "just the number" is, anyway? It has to be of some type on the JVM.
> And how do I opt out of using the java type in the db?
I don't understand what you're trying to opt out from. MongoDB Java driver stores
longs (which Clojure literals compile to) that way, presumably for a reason.
--
@michaelklishin,
github.com/michaelklishin