mongomapper

MongoMapper and migrations

I'm building a Rails application using MongoDB as the back-end and MongoMapper as the ORM tool. Suppose in version 1, I define the following model: class SomeModel include MongoMapper::Document key :some_key, String end Later in version 2, I realize that I need a new required key on the model. So, in version 2, SomeModel now loo...

How do i delete an embedded document in mongomapper?

Hi Guys I run a sinatra application with mongomapper. I have models called Movie(Document) and Cover(EmbeddedDocument).I embed covers into movies using @movie.covers << @cover @movie.save This works great. when hit @movies.covers I got the array of embedded documents. But I am not able to destroy the embedded document. I tried someth...

Mongoid or MongoMapper?

I have tried MongoMapper and it is feature complete (offering almost all AR functionality) but i was not very happy with the performance when using large datasets. Has anyone compared with Mongoid? Any performance gains ? ...

When to use Embedded Documents?

I am trying to figure out how to layout my database for a site I am working on. Here are my models: class User include MongoMapper::Document // keys here many :items many :likes end class Item include MongoMapper::Document key :name, String, :required => true many :likes end class Like include MongoMapper::Embedded...

MongoMapper Parent Inheritance

I am trying to get a better and organized result from using class inheritance with MongoMapper, but having some trouble. class Item include MongoMapper::Document key :name, String end class Picture < Item key :url, String end class Video < Item key :length, Integer end When I run the following commands, they don't quite ret...

MongoMapper has_many association

I have problem with mongomapper associations. I have one class names User and other named Model. User has many models but... user = User.first => <User ... user.models => [] Model.find_by_user_id(user.id.to_s) => <Model ... Model.find_by_user_id(user.id.to_s).user == user => true Class code (simplified): class User include MongoMap...

Mongomapper query collection problem

When I define the User has_many meetings, it automatically creates a "user_id" key/value pair to relate to the User collections. Except I can't run any mongo_mapper finds using this value, without it returning nil or []. Meeting.first(:user_id => "1234") Meeting.all(:user_id => "1234") Meeting.find(:user_id => "1234") All return nil....

Does MongoMapper (or any other Mongodb adapter) have a method like "accepts_nested_attributes_for"?

Hi there, I'm considering using mongodb on a new project, but before delving in, I'd like to know if it supports some key features. I know you don't need migrations, and you can add embedded objects,...but does all that mean it also behaves as if the 'accepts_nested_attributes_for' method is always there? Do you know of any other killer...

mongoDB, passenger and performance issues with phusion passenger

i just stumbled across a posing on the mongodb-user list where there was a discussion about passenger and forking when using mongoDB with MongoMapper. I just wanted to remind that Rails developers need to tweak their 'environment.rb' if they use MongoDB with Passenger. By default, Passenger spawns Ruby processes with fork(). A...

Inheritance with MongoMapper: searching the parent class

does it make sense to save the class name in a field when using inheritance with mongomapper/rails? class Item include MongoMapper::Document timestamps! key :class, String # does this actually make sense? key :title, String end class Post < Item key :body1, String end class Page < Item key :body2, String end if a sear...

:has_one relationship problem when using MongoDB

I have a pretty simple setup. To sum it up here's what I'm doing: class Movie include MongoMapper::Document has_one :setting end class Setting include MongoMapper::EmbeddedDocument belongs_to :movie end What I want to do is to update the setting of a movie in the same form as the movie other information. Therefor I do that : ...

Mongodb: What to know before using?

I'm starting a hobby (non-revenue) project using Ruby on Rails. I've done a fair amount of development in Rails using Postgresql, and I can make a pretty good imitation of normalized schema. However, Mongrodb looks shiny and new. What better for trying out something new than a hobby project? Think back to when you started using Mongo...

Order items in MongoDB according to the size of an array with MongoMapper?

I'd like to select a collection of items ordered based on the number of items within an array. Hopefully the following example will clarify my rather poor explanation: class Thing include MongoMapper::Document key :name, String key :tags, Array end I'd like to retrieve all Things ordered from those with the most tags to those w...

Sharing model definitions between Erlang and Rails (and mongodb)

I have a rails app using mongodb through mongomapper and all is well. The problem is... I'm going to want to use erlang to do some background processing and I want to update the same mongo/mongomapper models with the results of this processing. What's the best way to share model definitions between the two apps (rails and erlang) and rem...

Storing addtional info about a document in Mongo Mapper through a many :in => Array

I have a many to many relationship between Pumps and Parts. I am storing the Part ids in the Pump document. I would also like to store how many Parts are used in a particular Pump. Here's what I have, in short class Pump include MongoMapper::Document key :number, String key :desc, String key :part_ids, Array many :parts, :i...

activerecord and mongo / mongo-mapper bridge

I have a project which I have used Active Record and which I'd like to add some new features using MongoDB. Rather than re-invent the wheel and re-write my entire site, how can I integrate 2 models together, one which use MongoMapper and the other ActiveRecord (postgres). I've found that others have done it successfully, but no example...

mongodb data design question

I'm trying my first application with mongodb on Rails using mongo_mapper and I'm weighing my options on an STI model like below. It works fine, and I will of course add to this in more ways than I can currently count, I just curious if I wouldn't be better off with Embedded Documents or some such. I'd like my models to share as much as...

Describing Child objects with Cucumber/MongoDB

Ok, total Cucumber newbie here so please be gentle. As a learning Ruby/Cucumber/MongoDB endeavor I'm building a simple contact manager. I have a Person (parent) model and an have been able to write a simple test as follows: Scenario: Show people Given the following person exists | firstname | lastname | | Bob | Jones | W...

Return embedded documents in query

Is it possible to perform a query and return the embedded documents? Currently, I have: class Post include MongoMapper::Document many :comments end class Comment include MongoMapper::EmbeddedDocument belongs_to :post key :author key :date key :body end Here is a query that is almost there: Post.all("comments.date" ...

MongoMapper find EmbeddedDocument

Hi, I'm a little stuck with the concept of EmbeddedDocuments in MongoMapper. My Models look like this: class Post include MongoMapper::Document many :categories many :qualities end class Category include MongoMapper::EmbeddedDocument belongs_to :post many :qualities end class Quality include MongoMapper::EmbeddedDocume...