mongoid Questions

4

Solved

I'm starting a new app and notice some missing documentation from the last time I built a MongoID app from scratch. Namely they used to suggest on a page that no longer exists (http://mongoid.org/d...
Burchfield asked 28/4, 2011 at 22:13

4

Solved

Since Mongoid.master.collection() returns a collection even if the collection doesn't exist, we can use coll = Mongoid.master.collection('analyticsCachedResult') if coll.count == 0 # [...] end ...
Caddoan asked 23/9, 2010 at 21:58

5

I read up to inheritance in mongoid and it seems that all inherited classes will save in the base class, e.g. class BaseClass end class ChildClass1 < BaseClass end class ChildClass2 < Base...
Sanatorium asked 15/3, 2012 at 16:47

2

class Foo include Mongoid::Document end class Bar < Foo end Foo.all returns Bars, and Bar.all returns Foos. I want to put Foo and Bar in separate collections. I tried class Bar < Foo ...
Maroney asked 4/5, 2015 at 18:54

7

Solved

I have recently upgraded my ubuntu from 14.10 to 15.04. All features seems to be working fine except MongoDB. I am using mongoDB with ruby on rails application using Mongoid gem. MongoDB is not con...
Visible asked 4/5, 2015 at 7:46

4

Solved

The data type of the field is String. I would like to find the length of the longest and shortest value for a field in mongoDB. I have totally 500000 documents in my collection.
Ophir asked 16/10, 2014 at 2:46

4

Solved

So I'm writing a rspec test. It will test if a model is duplicated correctly. So the spec is something like this: it "should copy the data" do @model = build(:model) @another_model.copy_data(@...
Singer asked 2/10, 2013 at 18:33

4

Solved

I wasn't able to find any information on the max length for a string data type in MongoDB on the main mongodb.org site. I'm coming from a relational database background and there are usually max le...
Marcelmarcela asked 31/5, 2012 at 5:17

5

I am using Rails 3 and Mongoid gem. But I need to fill a combobox with the list of mongodb databases. In mongodb shell we can list databases with "show dbs" command. Also there is getDBNameList() a...
Towle asked 28/2, 2011 at 13:57

3

Solved

I have this little test script: require 'mongo' mongo_client = Mongo::Client.new(['127.0.0.1:27017'], :database => 'test') mongo_client[:collection].insert_one({a: 1}) An this is the console...
Vagarious asked 17/5, 2015 at 21:0

4

Solved

i tried something like this in rails with mongoid 3.1.0 and lastest 3.1.3. .limit does not work. below it should return 1 row but it returns all (4) code: @go = Gallery.limit(1) logger.info "coun...
Artful asked 18/4, 2013 at 4:18

3

Solved

I'd like to make a form that lets a user edit one field of a mongoid object as rendered JSON text. There's a field in the model that my rails app should not understand, but I want to expose a gener...
Jeu asked 12/1, 2013 at 0:5

2

Solved

I have found some information to accomplish this in mongoDB, but I need it with mongoid. So I can do something like: User.last(7000).each do .... I'm using: MongoDB shell version: 2.4.3 Mongoi...
Drupe asked 23/5, 2013 at 17:9

2

Solved

Following this question which @NeilLunn has gracefully answered, here is my problem in more detail. This is the set of documents, some have user_id some don't. The user_id represent the user who c...
Warrior asked 5/3, 2014 at 8:15

5

Solved

I want to port a social network to Mongoid. The join table between friends is very large. Is there any way for Mongoid to handle this join table out of the box? I've seen a couple of in-model roll-...
Encephalic asked 26/7, 2010 at 3:49

7

Solved

In my Rails API, I'd like a Mongo object to return as a JSON string with the Mongo UID as an "id" property rather than as an "_id" object. I want my API to return the following JSON: { "id": "53...
Intracellular asked 6/5, 2014 at 21:58

2

Solved

I have been facing this error when I try to call my api using GET /lecture_events/1. The error is ArgumentError (wrong number of arguments (given 2, expected 0..1)): app/controllers/lecture_event...
Lianna asked 22/2, 2022 at 18:15

2

Solved

Is there a built-in way to make upsert (insert if not exists) in Mongoid? Or should I check if an item exists first and only after that make insert/update?
Sanjak asked 11/11, 2012 at 2:17

4

Sample Documents: { time: ISODate("2013-10-10T20:55:36Z"), value: 1 } { time: ISODate("2013-10-10T22:43:16Z"), value: 2 } { time: ISODate("2013-10-11T19:12:66Z"), val...
Pretended asked 24/4, 2013 at 11:43

4

Solved

I have an array of made up of type BSON::ObjectId and I want it to compare against some IDs as strings. if my_array_of_BSON_ObjectIds.include?(@my_id_as_a_string) # delete the item from the arra...
Jock asked 25/9, 2012 at 8:17

4

Solved

I need to convert an embedded document onto its own collection, so it can be referenced from another collection. Lets suppose I have a Parent that embeds many Childs. I was thinking of something a...
Pitsaw asked 16/3, 2012 at 0:17

3

Solved

I'm using elasticsearch-rails and mongoid I have the following simple mapping with fields: "title": { "type": "string", "fields": { "raw": { &q...
Sunnysunproof asked 26/7, 2015 at 21:52

2

Solved

I'm using Rails 6.1, on Mac Sierra, and trying to install Mongodb as the database, already installed mongo db service on bash, and gem, however when I type: bin/rails g mongoid:config It shows the...
Unwieldy asked 31/12, 2020 at 15:58

2

i am new to mongodb and stack overflow. I want to know why on mongodb collection ID is of 24 hex characters? what is importance of that?
Gratianna asked 18/8, 2014 at 4:6

8

Solved

I tried @posts = Post.page(params[:page]).per_page(10) and @posts = Post.paginate(:page => 1, :per_page => 10) but neither method works undefined method `page' for Post:Class undefin...
Mcelhaney asked 18/12, 2011 at 1:40

© 2022 - 2025 — McMap. All rights reserved.