Questions tagged [mongoid3]

Version 3 of Mongoid, an Object-Document-Mapper (ODM) for MongoDB with Ruby. Use this tag for questions relating to this specific version.

Version 3 of Mongoid (an Object-Document-Mapper (ODM) for MongoDB). For a deeper description of Mongoid, see the main Mongoid tag.

Primary tag:

211 questions
3
votes
2 answers

Mongoid: How to validate value of specific key on Hash field?

In Mongoid, I can set an index on the attribute of a field whose type is Hash as follows: index({ "details.fullName" => 1 }, { name: "full_name_index" }) What I'd like to do is create validations for such entities using something like the…
Austin York
  • 808
  • 2
  • 10
  • 24
3
votes
1 answer

Parent Object In Mongoid Embedded Relation Extensions

Given a simple embedded relationship with an extension like this: class D include Mongoid::Document embeds_many :es do def m #... end end end class E include Mongoid::Document embedded_in :d end You can say things like…
mu is too short
  • 426,620
  • 70
  • 833
  • 800
3
votes
1 answer

Retrieve index of item in array in MongoDB

similar to -Aggregation: add option to $unwind to emit array index -Get index of an item within mongodb query I have this use case. Tastiest Fruit Rankings: {"date": "Jan 1st", "fruit_ranking": ["Apple", "Orange", "Grape", "Kiwi", "Mango",…
makeshifthoop
  • 127
  • 1
  • 8
3
votes
1 answer

Failing Rspec only with Zeus with undefined method for existing field declared with Mongoid using STI design pattern

Using Rails 4, Zeus 0.13.3, rspec-rails edge and mongoid edge Simple STI model: File my_model.rb in /model directory class MyModel include Mongoid::Document field :my_field end File my_sti.rb in /model/my_model directory class MyModel class…
Alex
  • 4,367
  • 5
  • 29
  • 45
3
votes
2 answers

MongoDB Ruby aggregation with dates

I'm having trouble with the MongoDB ruby driver (via mongoid) using aggregation. I would like to match against a date using comparison operators. match = { '$match' => { 'created_at' => { '$gte' => DateTime.parse('2012-08-01') } } } group = {…
David T
  • 765
  • 6
  • 18
3
votes
0 answers

Executing custom command with Mongoid 3.1

I'm trying to run custom javascript command under Mongoid 3.1 User.collection.database.session.cluster.with_primary do p User.collection.database.command(eval: 'function() { return 3+3; }') end And i have only this…
3
votes
1 answer

What type to store time length with Mongo

What type should i use to store time length with MongoDB? I need to store time length of sound data. so Timestamp type doesn't seem right.
kymmt
  • 75
  • 2
  • 9
3
votes
0 answers

Mongoid performance bombs as concurrency increases

I have a Rails(3.2.8)/Mongoid(3.0.6) app which uses Resque workers to generate and send emails each morning. Each Resque job has to query a few collections to generate the email and then perform the actual send. We have compound indexes set up to…
ccurtisj
  • 388
  • 2
  • 13
3
votes
1 answer

Mongoid Embeds_many won't save on nested form

I've got an embeds_many association I'm trying to set up which I've done successfully before, but I'm trying to do it all in one nested form and I can't figure it out. Let's say we have a pocket model: class Pocket include Mongoid::Document …
BJ McDuck
  • 164
  • 1
  • 12
3
votes
3 answers

How to reset a mongoid 3 database connection

In Mongoid 2.x one could execute Mongoid.database.connection.close to reset a database connection. This specific API is no longer available in Mongoid3, what is the new way to reset a connection? Motivation: interrupting a query while it's…
ccurtisj
  • 388
  • 2
  • 13
2
votes
1 answer

Make multiple delays in chained transitions in D3.JS

I am moving a rectangle from point a to point i in a picture, i want to mark a stop delay of 5s for each point (there are 8 points). the transitions work fine in the code below (the delay works only for point b).The problem is that i can't add more…
HazimoRa3d
  • 517
  • 5
  • 12
2
votes
0 answers

Rspec tests are slower when I change the position of the validations in the model

I have a big rails application in which I have tons of models. I have reorganized the content of the models to follow a common pattern (positions of the fields, constants, relations, validations, hooks and so on on all files). After finishing of…
2
votes
1 answer

Is mongoid automatically indexing the field _id?

I am on my first experience with noSQL databases, using mongodb. I am using Ruby-2.2.2 with Rails-3.2.22 and mongoid-3.17 I've seen that the Mongoid automatically includes an _id field in the models. BUT, Do I need to manually create an index for…
Fran Martinez
  • 2,994
  • 2
  • 26
  • 38
2
votes
1 answer

Moped::Errors::OperationFailure when creating an embedded object

I'm using mongoid 3.1.4 altogether with moped 1.5.1, mongodb 2.4.1, and ruby 1.9.3. I have next models: class Practice include Mongoid::Document embeds_many :distresses end class Distress include Mongoid::Document embedded_in…
mgallardoz
  • 51
  • 4
2
votes
1 answer

Atomic inc of multiple mongoid hash values

I have a Mongoid model with a hash field that looks like this: class DimensionStat include ::Mongoid::Document include ::Mongoid::Timestamps field :data, type: Hash attr_accessible :data end I pretend on runtime fill data with something…
Carlos Castellanos
  • 2,358
  • 4
  • 25
  • 43
1 2
3
14 15