Questions tagged [monger]

Monger is a Clojure MongoDB client

Monger is a Clojure MongoDB client

51 questions
8
votes
1 answer

Prevent mongodb from dying with 'state should be: open'

I'm using mongodb in a multithreaded clojure app, using the monger library, and one of my producer threads are dying with java.lang.IllegalStateException: state should be: open at com.mongodb.assertions.Assertions.isTrue (Assertions.java:70) …
expez
  • 399
  • 3
  • 15
7
votes
2 answers

Mapping Mongodb ObjectId to and from string automatically

I am accessing Mongo database from Clojure using Monger library. One thing that annoys me is switching back and forth between ObjectId instances and strings. For example, the this code (mc/find-maps "posts" {}) will evaluate to maps with the value…
Goran Jovic
  • 9,418
  • 3
  • 43
  • 75
6
votes
2 answers

MongoDB Connection Pattern using Monger

I am new to clojure. Are there any idioms/patterns around connecting to mongodb through monger? Do I have to connect and disconnect using (monger.core/connect) & (monger.core/disconnect conn) respectively. each time ? Is there a way I can reuse a…
Aneesh
  • 928
  • 10
  • 20
5
votes
2 answers

Return updated document with Monger

In Monger there is a insert-and-return function for returning a newly inserted document. There is no update-and-return function. How can I return an updated document from the function that executes the update? I think I could use save-and-return but…
tobiasbayer
  • 10,269
  • 4
  • 46
  • 64
4
votes
3 answers

Clojure: Aggregate and Count in Maps

I guess this question qualifies as an entry-level clojure problem. I basically have troubles processing a clojure map multiple times and extract different kinds of data. Given a map like this, I'm trying to count entries based on multiple nested…
frhd
  • 9,396
  • 5
  • 24
  • 41
3
votes
1 answer

The connection string is invalid mongo db

I am using monger to connect with the database, but I'm getting that the connection string is invalid: Caused by: java.lang.IllegalArgumentException: The connection string is invalid. Connection strings must start with 'mongodb://' Here's my code…
zendevil
  • 899
  • 4
  • 13
  • 26
3
votes
1 answer

Clojure - How To Properly Mount State In Unit Tests

I'm attempting to test some database operations in a luminus app with the Monger database library. Ideally, I'd like the following to work. I've stripped out some of the irrelevant code. Test File: (ns app.test.handler (:require [clojure.test…
newBieDev
  • 484
  • 3
  • 11
3
votes
1 answer

Monger Missing codec for java.math.Bigdecimal

Trying to Insert a Document to Mongo using Monger With a Float/Big Decimal in it (mc/insert db "products" {:name "Shirt" :Price 300.00M }) and gets the following Error . ERROR compojure.api.exception - Can't find a codec for class…
Rishin S Babu
  • 1,553
  • 3
  • 13
  • 16
3
votes
1 answer

Clojure <-> Monger <-> MongoDB: reading and writing a set

I'm using Monger to store data in MongoDB. I would like to store a Clojure set. Reading and writing the set does work, but it is returned as a list. I suspect MongoDB doesn't actually support the set data type, so the Monger client doesn't either,…
Martin Dow
  • 5,273
  • 4
  • 30
  • 43
2
votes
1 answer

How To Unit Test MongoDB with Luminus?

I'm probably missing something simple, but I'm not experienced enough with clojure to understand the error I'm getting. I have a simple luminus clojure app setup with the Monger library to handle my MongoDB connection. I've added a simple test that…
newBieDev
  • 484
  • 3
  • 11
2
votes
1 answer

Clojure - Monger Operators - missing multiple field concat and query support with Date conversion

I have a data set on mongo like: {"month": 9, "year": 2015, "name": "Mr A"} {"month": 9, "year": 2015, "name": "Mr B"} {"month": 10, "year": 2015, "name": "Mr B"} {"month": 11, "year": 2016, "name": "Mr B"} I am trying to get the minimum date from…
Mrinal Saurabh
  • 948
  • 11
  • 16
2
votes
1 answer

java.lang.RuntimeException: java.lang.NoSuchMethodError: when running clojure web app

I'm trying to run a small Clojure web app I wrote, and I'm getting an exception from lein ring server that isn't giving me any useful information. I've googled the error and found this discussion, which suggested running lein deps :tree to route out…
Levi Campbell
  • 6,005
  • 7
  • 40
  • 47
2
votes
1 answer

Is there an efficient way to group records by day according to a specific time zone?

I’m using a MongoDB database to keep track of analytics for an application. I’m writing a Clojure application (using clj-time and Monger) to get data out of the database. I have a collection containing records like {"_id": ObjectId(...), timestamp:…
bdesham
  • 15,430
  • 13
  • 79
  • 123
2
votes
2 answers

Read-only connection to a slave instance using monger

I have a replica set and I want to establish standalone read-only connection to a slave instance. Normally, I should experience no problems doing it. The only thing I ought to do is to set slaveOk=true to be able to query it with read operations. It…
Leonid Beschastny
  • 50,364
  • 10
  • 118
  • 122
2
votes
1 answer

How to update / insert a MongoDB sub document with Monger?

I'm using Clojure's Monger library to connect to a MongeoDB database. I want to update, insert & remove subdocuments in my Mongo database. MongoDB's $push modifier lets me do this on the root of the searched document. But I want to be able to $push…
Nutritioustim
  • 2,686
  • 4
  • 32
  • 57
1
2 3 4