Rails, Mongoid & Unicorn config for Heroku

You dont actually need to do this, so for people coming to view this question see: http://mongoid.org/en/mongoid/docs/rails.html “Unicorn and Passenger When using Unicorn or Passenger, each time a child process is forked when using app preloading or smart spawning, Mongoid will automatically reconnect to the master database. If you are doing this in your application … Read more

Spring Data MongoDB: how to implement “entity relationships”?

You can use the @DBRef annotation to persist the referenced class in a separate collection, else the document will be persisted in the same document (json). The use of DBRef require an extra query for the mongodb driver, you should consider this to analyze performance issues. From spring data documentation @DBRef – applied at the … Read more

Mongodb aggregation pipeline how to limit a group push

Suppose the bottom left coordinates and the upper right coordinates are respectively [0, 0] and [100, 100]. From MongoDB 3.2 you can use the $slice operator to return a subset of an array which is what you want. db.collection.aggregate([ { “$match”: { “loc”: { “$geoWithin”: { “$box”: [ [0, 0], [100, 100] ] } }} … Read more

find by _id with Mongoose

Because this query finds the doc in the shell: db.getCollection(‘stories’).find({_id:’572f16439c0d3ffe0bc084a4′}) That means that the type of _id in the document is actually a string, not an ObjectId like Mongoose is expecting. To find that doc using Mongoose, you’d have to define _id in the schema for Story as: _id: { type: String }

Running MongoDB Compass on Mac

System Preferences >> Security & Privacy >> General >> [Unlock]>> Allow apps Downloaded from >> You will find an alert specifically for MongoDB Compass Previously there was an option to enable from “Anywhere”. Now it’s removed.

Can MongoDB use an index when checking for existence of a field with $exists operator?

Updated: Seems $exists queries use index properly now based on these tickets $exists queries should use index & {$exists: false} will not use index Old Answer: No, there is no way to tell mongodb to use index for exists query. Indexing is completely related to data. Since $exists is only related to the keys (fields) … Read more