Monger Unsupported OP_QUERY MongoDB

I am attempting to use Monger in a project:

Following those directions, I :require some key parts:

[monger.core :as mg]
[monger.collection :as mc]

Then I try to insert a document:

(mc/insert db "items" params)

I get the error:

Command failed with error 352: 'Unsupported OP_QUERY command: insert. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal

I puzzled by the idea that I need an upgrade. I just set up a new AWS EC2 instance running Ubuntu 24 and installed the latest version of MongoDB.

mongod --version
db version v8.0.3

So that is modern.

What is it that I have to upgrade?

The error message mentions a client update. Meaning, Monger itself. Or, more likely, something that it uses under the hood.

Probably relevant: Latest version uses MongoDB java driver 3.12 which only supports MongoDB up to 4.2, which is out of support this coming April 2023.... **SOLVED** · Issue #225 · michaelklishin/monger · GitHub

In other words, the library hasn’t been updated in quite some time. You can either use the driver directly or fork the library and update what’s needed.

Would you happen to know if there is a well supported Clojure library for working with MongoDB?

As you say, I could fork the library, but then I d be responsible for its maintenance. I’m at a small startup and cannot afford the time it would take.

MongoDB is the opposite of my “DB of choice” so no, not really.

If you fork something, you’re only responsible for the maintenance that’s required for your own project. So it would be like your own code, albeit with its own license and copyright. You won’t be responsible for fixing bugs that you don’t experience and making updates that you don’t need.

1 Like

At work we’re using GitHub - gnarroway/mongo-driver-3: A Mongo client for Clojure, lightly wrapping 3.11/4.0+ versions of the Java driver - it uses the new Java driver for Mongo.

I wouldn’t recommend forking Monger - its API is quite different from how the new client works and it uses features that changed quite heavily in the new one.

Fun fact: I wrote a layer around mongo-driver-3 to make it work like Monger (because that was easier than rewriting all of the code) and while it was a fun project I wouldn’t recommend it.

1 Like

Okay, this looks great. I will try this tonight.