Skip to main content
0 votes
1 answer
268 views

$all not working with array

I am trying to get all submissions documents that contain all of the tags listed in an array. My current code looks like this: submissions.find({ tags: { $all => tags } }) print tags.count ...
Ethan McTague's user avatar
0 votes
1 answer
714 views

Finding the size of a Mongo::Collection::View

I am trying to find the size of the result of a query in MongoDB and ruby: size = collection.find({ foo: 'bar' }).size if size > 0 print "There are #{size} results!" else print "There aren't ...
Nova Wolf's user avatar
4 votes
0 answers
181 views

Sporadic NoServerAvailable errors from mongoid

On production we get a steady stream of seemingly random Mongo::Error::NoServerAvailable errors. Maybe 3 a day. The replica set in question has not experienced any elections, and there is nothing ...
cailinanne's user avatar
  • 8,372
0 votes
1 answer
399 views

MongoDB returns wrong results for count query

> filters = {search_created_at: {$lte: ISODate("2016-04-28T23:25:31.818Z")}} { "search_created_at" : { "$lte" : ISODate("2016-04-28T23:25:31.818Z") } } > db.collection_name.find(filters).count() ...
bill_cosby's user avatar
1 vote
1 answer
647 views

Ruby Mongo Driver Projection Elemmatch

Following the code in http://www.w3resource.com/mongodb/mongodb-elemmatch-projection-operators.php I have set up a test database using the ruby mongodb driver. For those following along at home, you ...
Elias's user avatar
  • 11
0 votes
1 answer
337 views

How To Update 1 row of data in MongoDB (Ruby)

If I have the below code for inserting data in using mongodb, how can I update it's value. I'm confuse with the setting of arguments in update_one/update_many function. require 'mongo' require 'json/...
aldrien.h's user avatar
  • 3,723
2 votes
1 answer
419 views

Using DBRef in mongo ruby driver: (undefined method `bson_type' for #<Mongo::DBRef:0x0056466ed55e48>)

When I try to use DBRef in the mongo ruby driver (creating a new DBRef object and including in a document which I am inserting into a collection), I get this error that I cannot make heads nor tails ...
Ariel Goldblatt's user avatar
0 votes
0 answers
877 views

load balancing between multiple mongos instances in mongodb cluster

I have several mongos instances. I have ruby and node.js application. I can put the hosts of all the mongos instances to mongodb connection URI. The ruby and node.js drivers can handle the failover. ...
BAE's user avatar
  • 9,056
0 votes
1 answer
1k views

Insert an array of Ruby objects in a Mongo database

So, I'm using the Ruby MongoDB driver and I want to insert and object like this: db.insert_one({ 'game_id' => @token, 'board' => { 'tiles' => @board.tiles } }) where @board is an ...
Marcos's user avatar
  • 4,663
0 votes
1 answer
987 views

Connecting to Mongod via Ruby driver using SSL returns Mongo::ConnectionFailure

I want to use SSL with MongoDB. It's not enabled by default so one has to compile from source with the necessary options. I followed the official documentation and got the v2.6.4 binary built and ...
andyroberts's user avatar
  • 3,518
0 votes
1 answer
872 views

ruby mongodb driver push to array

Lets say I have a document Person, and I wish to add Tags to this document. So I would like a document to look like { "_id" : 5, "tags" : ["Music", "Baseball", "Skiing"] } Everytime a person ...
Srikanth Venugopalan's user avatar
0 votes
1 answer
1k views

Update nested hash MongoDB - Ruby

I'm trying to update a hash in a MongoDB doc with a simple value but it store the value in an array. I use the ruby driver for mongo Code will explain better because my english is bad. What I have : ...
chambo_e's user avatar
0 votes
1 answer
265 views

Mongo Group function call in Ruby

I have a mongodb collection like this {"assigneeId" => 1000, "status" => 3, "starttime" => "2014 Feb 25", "numofdays => 6} {"assigneeId" => 1000, "status" => 2, "starttime" => "2014 Jan 10", "...
Sivaram Kannan's user avatar
-1 votes
1 answer
1k views

Mongodb query with multiple $nin

I took this example: db.inventory.update( { tags: { $nin: [ "appliances", "school" ] } }, { $set: { sale: false } } ) form the mongodb.org website. Whenever I try to use $nin multiple times, ...
meso_2600's user avatar
  • 2,146
1 vote
0 answers
76 views

Mongomapper throwing error message multiple times

I have a simple Model - Shop in my Ruby/MongoMapper application. I have no idea why sometimes I only get one error message, and sometimes I get three error messages like this one: 'Validation failed:...
meso_2600's user avatar
  • 2,146

15 30 50 per page