Questions tagged [mongodb-ruby]

Officially supported Ruby driver for MongoDB.

The MongoDB Ruby driver is the officially supported Ruby driver for MongoDB. It’s written in pure Ruby and is optimized for simplicity. It can be used on its own, but it also serves as the basis of several object mapping libraries, such as Mongoid.

Links

Related tags

50 questions
0
votes
1 answer

Simple MongoDB query on HASH not working as expected (only in some conditions)

Ok, it's a bit complex so i'll try to be clear. I have a structure I use to build some sort of ticket system. Parent Collection: Thread Embedded Collection: Message (a Thread embeds 0..N Messages) In a message I have an attribute "read_time" of…
Alex
  • 4,367
  • 5
  • 29
  • 45
0
votes
1 answer

Rails 3 + MongoDB: Render Json Without a Field

render :json => @bs.to_a.to_json, :except => ["completo"] I want to render everything to json except the field "completo". That should be working but given that I need to do ".to_a" and ".to_json", that stopped working. Is there a way to…
Donald
  • 243
  • 4
  • 10
0
votes
1 answer

Ruby Mongo Driver: How To Look For Date Intervals?

Given a init date and today, what's the query to search for all "names" between that date? Thank you
donald
  • 23,587
  • 42
  • 142
  • 223
0
votes
2 answers

Can you create multiple indexes on a single field in Mongo? What does that look like?

I'm trying to create a compound key as my "_id" field, which takes in some geo information as well as other attributes. It looks something like: {_id: {lat: 50, lon: 50, name: "some name"}} After creating the document, mongo assigns an index by…
etang
  • 730
  • 8
  • 23
0
votes
1 answer

Rails code generated with ORM mangomapper throws NoMethodError (undefined method `each' for "4d2aeaea4403baa84a000005":String)

I am absolutely totally news to Rails and to MongoDB. I have been following tutorials from a good book and create my first Rails app with a light Twitter copy. Everything went fine and smooth. But as part of my learning process I wanted to build the…
Alex
  • 4,367
  • 5
  • 29
  • 45
0
votes
1 answer

MongoDb capped collection

can u help me pls as i surfed around but didn't find any information. I'm working with mongoDB capped collection using Ruby. I need to update documents according to the id i retrieve from the query, but it never works. here is the example of my…
Kuen
  • 163
  • 2
  • 4
  • 13
0
votes
1 answer

$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 However, upon running, I receive the following error on the…
Ethan McTague
  • 2,236
  • 3
  • 21
  • 53
0
votes
1 answer

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 any results." end However, when I run this, I get the…
Nova Wolf
  • 3
  • 3
0
votes
1 answer

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() 18371526 > >…
bill_cosby
  • 145
  • 2
  • 9
0
votes
1 answer

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/ext' client = Mongo::Client.new([…
aldrien.h
  • 3,437
  • 2
  • 30
  • 52
0
votes
0 answers

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. But can the two drivers do balancing between the…
BAE
  • 8,550
  • 22
  • 88
  • 171
0
votes
1 answer

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 instance of a Board class. class Board attr_accessor…
Marcos
  • 4,643
  • 7
  • 33
  • 60
0
votes
1 answer

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 running nicely on a freshly deployed server running…
andyroberts
  • 3,458
  • 2
  • 37
  • 40
0
votes
1 answer

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 chooses an interest, I would like to append it to the…
Srikanth Venugopalan
  • 9,011
  • 3
  • 36
  • 76
0
votes
1 answer

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 : { 'id' : ... 'stream' : { …
chambo_e
  • 74
  • 2
  • 8