Questions tagged [mongoid6]

Mongoid 6 is major version 6 of Mongoid, the officially supported ODM (Object-Document-Mapper) framework for MongoDB in Ruby.

Ruby ODM framework for MongoDB.

Docs for Mongoid 6.

Mongoid community projects https://github.com/mongoid

29 questions
4
votes
1 answer

mongodb, lookup by hash key

I have a collection like this: Category: {_id: Object:Id(...), code: 'drink', name: 'Soft Drink and Beer'} {_id: Object:Id(...), code: 'fast-food', name: 'Burger and Chicken Fry'} GroupPeople: {_id: Object:Id(G1), categories: {'drink' => 5,…
Peter89
  • 706
  • 8
  • 26
2
votes
1 answer

Rails 6 + Mongoid 6.1.0 not compatible versions for gem "activemodel"

Trying to use Rails 6.0.0 with Mongoid 6.1.0 gem 'rails', '~> 6.0.0' gem 'mongoid', '~> 6.1.0' Tried already to not set the mongoid version in Gemfile, but still not working. Bundler could not find compatible versions for gem "activemodel": In…
pipinha
  • 195
  • 1
  • 10
2
votes
2 answers

Ruby on Rails, Can I get the current count of connections in Mongoid pool?

I have set min_pool_size to 100 in mongoid.yml but in mongo when running db.serverStatus().connections i only get 30. Is there a way to check how many connections I have in pool?
user793789
  • 196
  • 1
  • 13
2
votes
0 answers

Mongoid group and count by week

In a Rails app with mongoid, given a collection with a created_at field, how would you return the number of records created for each week ? I found somewhere a trick to add def created_at_week created_at.strftime('W%W %Y') end so I can do…
2
votes
2 answers

Mongoid greater than date or not nil

I have two models class Conversation include Mongoid::Document field :last_moderated_at, type: DateTime has_many :messages end class Message include Mongoid::Document include Mongoid::Timestamps end I want to get the list of all…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
1
vote
0 answers

Mongoid, stranger mongodb query when uses belongs_to relation

I'm using mongoid 6 and I have this two models in my project: class User belongs_to :project end class Project has_many :users end When I access to project from user instance I see this mongodb log: > user.project ... DEBUG -- : MONGODB ...…
rjurado01
  • 5,337
  • 3
  • 36
  • 45
1
vote
1 answer

Update Attributes Error Unknown modifier: $pushAll (9)

When I execute update Attributes in my model update_attributes prod_id: 34978273492, it returns Unknown modifier: $pushAll (9). What is the root cause. TIA
Amar A
  • 65
  • 8
1
vote
2 answers

WARN -- : MONGODB | Unsupported client option 'raise_not_found_error'. It will be ignored

I need to setup option in mongoid.yml. It work in development but production in heroku gave the ignore warning message. Is anyone experience and how to fix this ? W, [2017-04-05T02:04:09.447207 #4] WARN -- : MONGODB | Unsupported client option…
PKul
  • 1,691
  • 2
  • 21
  • 41
1
vote
1 answer

how to delete a key from mongoid hash field

I have a hash field in Mongoid document like < _id: 58a202d407953817ece2989c, d: {"a"=>"b", "c"=>"d"}> i want to pop key a from it so that hash filed contain only c how to do this in mongoid?
Aki Singh
  • 11
  • 1
1
vote
2 answers

Mongoid field hash as Struct

Is it possible to configure a mongoid field to deserialize as a Struct rather than a Hash ? (with defaults) My use case : a company with a subscription plan stored as a hash in my model. Previously as a hash class Company include…
0
votes
2 answers

Mongoid aggregation with conditions

I'm using the mongoid 6.1.0 aggregation framework in my Rails 5 project. I need to add a $match pipeline if the value of a search field (text or select field) is not empty. Otherwise, it should be ignored and don't filter results. Something…
0
votes
1 answer

Manage User Roles based on Projects in rails and mongoid

I am using rails and MongoId. I have 3 models - User, Project and Role. I want to manage user roles based on projects. For example: user1 has assigned to 2 projects, for project1 user1 may be admin, for project2 user1 may be a Quality Analyst. How I…
krishna m
  • 73
  • 1
  • 7
0
votes
1 answer

MongoDB Aggregation push zero in keys while doing group

I am not sure that this is a valid question or not. I have started working on mongodb aggregation. I have to make a graph for the data on daily, weekly, monthly basis. I am using "$dayOfMonth", "$week", "$month" to group by depending on the date…
thedudecodes
  • 1,479
  • 1
  • 16
  • 37
0
votes
1 answer

Mongoid 6.3 where in query not working

Rails app with MongoDB. Rails version 5.1.6 And mongoid version 6.3.0. Following query doesn't seem to work: User.where(:role.in => ['admin', 'supervisor']).count Above query returns 0. But following query User.where(:role.in =>…
rAzOr
  • 300
  • 6
  • 19
0
votes
1 answer

Mongoid find_by any language for a localized field

Using Mongoid / MongoDB, how can I find a document whose name in either available language match my where query ? Assume I have a model with a localized field and many translations class Foo field :name, localize:…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
1
2