Skip to main content

Questions tagged [mongoid]

Mongoid is the official Ruby Object-Document-Mapper (ODM) for MongoDB.

mongoid
0 votes
2 answers
44 views

Rails Mongoid has_many query not using foreign_key

I am using mongodb for first time. I have below models class Legacy::User include Mongoid::Document has_many :customers field :username, type: String end class Legacy::Customer include ...
pramodtech's user avatar
  • 6,400
1 vote
1 answer
34 views

Mongoid: Querying embedded (embeds_many) documents

These are my classes: class Ticket include Mongoid::Document embeds_many :transitions end class Transition include Mongoid::Document embedded_in :ticket field :to, type: String field :...
Mattix's user avatar
  • 47
0 votes
0 answers
42 views

Query plan stage appears to be a bottleneck in mongoid, what am I doing wrong?

I experience problems with query performance in Mongoid. The major part of time is taken by query plan but not query itself (the relation is 5-to-1) and this is not being changed after a number of ...
peresvetjke's user avatar
0 votes
1 answer
69 views

Wrong parsing of array of float when using HTTP verbs in Rspecs test

I have defined the following classes: shop.rb: class Shop field: :reputation, Float embeds_one :location, class_name: "Location" accepts_nested_attributes_for :location end ...
Baltasar del Sol de Haro's user avatar
0 votes
0 answers
25 views

Mongoid: query documents that have has_one relation

I have these models class Employee has_one :device end class Device belongs_to :employee end I want to find all employees with a device. I tried different approaches: Employee.where(:'device'....
Mattix's user avatar
  • 47
0 votes
1 answer
40 views

Mongoid polymorphic associations with embeds

I'm confused on how to make polymorphism work with embeds and mongoid 8.x. class Entity include Mongoid::Document embeds_many :custom_fields, as: :item end class EmailField include Mongoid::...
ngw's user avatar
  • 1,262
0 votes
1 answer
54 views

query efficiency on single embedded document in mongodb / rails

My question is about efficiency and perhaps good practices. I am envisioning the following data model in rails with mongoid: class Subscription ... some attributes... embeds_one :schedule # ...
Boenne's user avatar
  • 616
0 votes
1 answer
40 views

How do I change the mongoid error message to a custom message?

In my app I am offering the user to 'subscribe' to a topic. I want to be able to show a custom message if they already are subscribed. I have a uniquness validation in my rails model using mongoid. ...
Boenne's user avatar
  • 616
0 votes
1 answer
24 views

Mongoid aggregation: $group partially after $project, or remove duplicates in a projected output

Let's say I have tagged conversations, and conversations have messages which have created_at and read_at(=nil). I'm looking to have, for all conversations in a tag, their unread messages and the last ...
Victor Pudeyev's user avatar
1 vote
0 answers
45 views

How to use $in with Mongoid?

How I setup my data in an rspec let(:first_origin) { create(:origin, owner: "123@tenant") } let(:second_origin) { create(:origin, owner: "123@tenant") } create_list(:ticket, 10, ...
ngw's user avatar
  • 1,262
1 vote
1 answer
266 views

How to use Azure Managed Identity to access Azure Cosmos db on ruby on rails?

I have a ruby on rails application. I am using mongoid gem to connect to Azure cosmos db for mongo service on azure. Currently, I use username and password for authentication. Instead of using ...
Vansh's user avatar
  • 65
1 vote
1 answer
90 views

Rails 6 Upgrade Not Loading Mongoid From a Concern

We're upgrading our app from Ruby 2.7 to 3.0 and Rails 5.2 to 6.0 at the same time (I started with just Ruby but 3.0 doesn't seem to be compatible with 5.2). It's close but getting an odd error: ...
timsegraves's user avatar
1 vote
0 answers
36 views

Mongoid returning the wrong count of documents

Mongoid 8.1.4 on latest MongoDB, I'm using pagy to paginate (which doesn't work out of the box, but can be fixed by overriding a method). My overriding: module PagyExtension module Mongoid def ...
ngw's user avatar
  • 1,262
0 votes
0 answers
57 views

Error When Connecting To Mongo Server Using IAM Role

I am using Mongoid gem in Rails with IAM session token to connect with my Atlas Cluster def logs reload_mongoid_configuration @logs ||= Log.or(attributes_condition) .where(selector)...
Hassan Anwer's user avatar
0 votes
0 answers
34 views

MongoId - Reference association not working - Rails 7

I have a Rails 7 app where my registration form only contains 2 fields: Company Name Email The registration involves the following models: Company Account User The associations involved are: A ...
Stf_F's user avatar
  • 1,044

15 30 50 per page
1
2 3 4 5
316