Questions tagged [monger]

Monger is a Clojure MongoDB client

Monger is a Clojure MongoDB client

51 questions
1
vote
2 answers

When using monger, do I need to supply connection each request?

In the documentation, the mongodb connection is established once, before being used without passing the connection to each command, is that the proper way to use monger, or should I pass the database connection to each call?
Levi Campbell
  • 6,005
  • 7
  • 40
  • 47
1
vote
1 answer

Not letting Monger serialize

I'm new to Clojure and I'm having issues with Monger. I'm trying to user Monger with Friend. I have this ns: (ns cemerick.friend-demo.users (:require [cemerick.friend.credentials :refer (hash-bcrypt)])) (def users (atom {"friend" {:username…
interlude
  • 843
  • 8
  • 29
1
vote
1 answer

Clojure convert {"a.b" 1, "a.c" 2, "d.e" 3} to {:a {:b 1, :c 2}, :d {:e 3}} (for compojure/hiccup with monger hierarchy)

My mongodb schema has a JSON hierarchy to it. When I get the field params from compojure, the hash is in flat dotted notation like {"a.b" 1, "a.c" 2, "d.e" 3}. I'm wanting to use monger to insert the data, but that expects a real hierarchical…
lobsterism
  • 3,469
  • 2
  • 22
  • 36
1
vote
1 answer

How do I add a document to mongodb with monger and Clojure?

I have never used MongoDb before, nor have I used Monger before. I am working on a Clojure app. I simply want to be able to add one document, as an upsert. This is some of my code: (defn convert-data-to-be-persisted [session-data] …
cerhovice
  • 676
  • 1
  • 10
  • 24
0
votes
1 answer

Monger session store

Following a previous question where I asked on how on earth do sessions work in Clojure, I have been experimenting with Monger. In the documentation, you can find the code snippet: (ns monger.docs.examples (:require [monger.core :as mg] …
Jack Gee
  • 136
  • 6
0
votes
1 answer

How to send an input stream as a response in ring?

I have the following code, in which I want to send an InputStream of a file in the function fetch-items, which handles the route /fetch-items. (defn id->image [image-id] (let [image (.getInputStream (gfs/find-by-id fs image-id))] image)) (defn…
zengod
  • 1,114
  • 13
  • 26
0
votes
0 answers

Unable to query mongodb using monger

I'm making the a query using monger like so: (let [uri mongo-uri {:keys [conn db]} (mg/connect-via-uri mongo-uri-only)] (defroutes myRoutes (GET "/someroute" req (let [user-id (:id (json/read-str (:body (get-user-info…
zengod
  • 1,114
  • 13
  • 26
0
votes
1 answer

How to use a monger connection globally in the server?

I have a mongodb database that I've connected to like so: (let [uri (config-keys :mongoURI) {:keys [conn db]} (mg/connect-via-uri uri)]) In Node.js with mongoose, one can do mongoose.Promise = global.Promise, to connect to the database only…
zengod
  • 1,114
  • 13
  • 26
0
votes
1 answer

How to use set/intersection with big result sets from MongoDB

I've a function photos-with-keyword-starting that gets lists of photos for a given keyword from a MongoDB instance using monger, and another that finds subsets of these photos using set/intersection. (defn photos-with-keywords-starting [stems] …
Eric Clack
  • 1,886
  • 1
  • 15
  • 28
0
votes
0 answers

Addind ISODate wrapper in Clojure

When I do a new Date() in an insert in Mongodb shell it gets added as shown below with an ISODate wrapper. ISODate("2017-12-06T12:56:01.908Z") But when I format a date as an ISO using joda-time and add it via monger(Clojure Mongo Driver) it gets…
Rishin S Babu
  • 1,553
  • 3
  • 13
  • 16
0
votes
2 answers

Running "repairDatabase" with Monger?

Is it possible to execute the "repairDatabase" command with Monger? If so how?
Johan
  • 37,479
  • 32
  • 149
  • 237
0
votes
1 answer

Setting ReadPreference in Clojure MongoDb Driver Monger

How do I set ReadPreference while using find-maps in Monger ? The Monger documentation only specifies the usage with with-collection of monger.query as shown below (ns my.service.server (:refer-clojure :exclude [sort find]) (:require [monger.core…
Rishin S Babu
  • 1,553
  • 3
  • 13
  • 16
0
votes
1 answer

which is faster? map or reduce with condition fn or get-in?

I am using monger and fetching a batch from my mongo nosql database using find-maps. It returns an array that I plan to use as a datastore argument (reference) downstream in my chain of function calls. Within those future function calls, I will have…
Benjamin McFerren
  • 822
  • 5
  • 21
  • 36
0
votes
1 answer

Querying by MongoDB ISODate in Clojure (monger/clj-time)

Disclaimer: Clojure noob. I'm trying to implement a simple get-shows function to return upcoming shows from a MongoDB instance. This returns a LazySeq of length 3, which is what I'd expect: (defn get-shows [] (let [date-str (f/unparse…
acobster
  • 1,637
  • 4
  • 17
  • 32
0
votes
1 answer

Use of search patterns with monger

I wish to access a mongo db from clojure using search patterns like this: find({Keywords: /search-pattern/}) I have a database called "soulflyer", containing an "images" collection and each member has a "Keywords" field containing an array of exif…
Iain
  • 300
  • 2
  • 13