Howdy guys,
I'm pretty new to mongodb (only work with it for one small project) and I wanted to have your tips on how to organize my documents. My brain is not (yet) nosql formatted.
I have a collection storing all kind of informations and I want to add tags to it. There will be 1-5 tags by document. I want to be able to search by tags ...
Hi there
I'm trying to run a query where I want to ignore records with a certain email address...
@foo = Bar.all(:email => 'xxx') <--- Except I want to negate where this email address exists.
Please let me know how I can do it.
Thanks!
...
I installed mongo mapper gem and have the version 0.8.2. I opened the environment.rb file and editing it to use MongoMapper as shown below:
# Be sure to restart your server when you modify this file
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
#...
I have stumbled upon Mongoid which has great documentation: http://mongoid.org/docs/associations/
But I have heard that MongomMapper is de-facto for Rails.
Where do I find API documentation for using Mongomapper?
...
Is it possible to combine AR with MongoMapper/MongoID?
If so, are there tutorials/documentations for this?
...
Hi together,
at the moment I'm doing some tests with MongoMapper.
When using relations, http://www.mongodb.org/display/DOCS/MongoDB+Data+Modeling+and+Rails sugests to use cached values where it fits...
I take a stripped down example from there:
class Story
include MongoMapper::Document
key :title, String
key :url, Str...
I have mongo_mapper set up like so:
class Person
include MongoMapper::Document
many :pets
end
class Pet
include MongoMapper::EmbeddedDocument
key :animal, String
key :name, String
key :colour, String
end
# Create a person
me = Person.new
# Add pets to the person
me.pets << Pet.new(:animal => 'dog',:name => 'Mr. Woofs', ...
I'm looking to Eager Load Associated Documents using MongoMapper. Say I have an author with a :has_one condition to a Post, I should be able to load the author using a single query
Post.find(:all, :include => :author)
Any suggestions?
...
Hi all:
This is just for my weekend project/study, I am very new to Sinatra and MongoDB.
I've installed the gems for mongoDB, such as: mongo, mongo_mapper and mongoid.
When I tried connecting to my database on MongoHQ from localhost, it encountered such an error:
Mongo::ConnectionFailure at /
failed to connect to any given host:port
...
Hi All,
How will I do authentication using Rails 2.3.8 using MongoDB and
mongo_mapper?
Let me know your expert advise on this.
By the way, a Rails noob here :)
Thanks!
...
Lets say we have a simple model that stores two integers, the min and the max. We would like to force min <= max.
class MinMax
include MongoMapper::Document
key :min, Integer
key :max, Integer
validate_presence_of :min, :max
end
1) How would you validate that min is indeed equal or less than max?
2) If you don't think this ...
From http://github.com/diaspora/diaspora/blob/master/spec/models/profile_spec.rb
describe Profile do
before do
@person = Factory.build(:person)
end
describe 'requirements' do
it "should include a first name" do
@person.profile = Factory.build(:profile,:first_name => nil)
@person.profile.valid?.should be false
...
gem 'rails', '3.0.0'
gem 'devise'
gem 'bson_ext', '>= 1.0.7'
gem 'bson', '>= 1.0.7'
gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
With the above setup I get the following errors on requests:
Starte...
I downloaded the mongo_mapper gem and it installed successfully. Now, I am using it in my app and it always throws exception "No file to load mongo_mapper". What is that supposed to mean?
require 'mongo_mapper'
include mongo
UPDATE: After using require 'rubygems' first. My original problem is gone now there is another weird problem: ...
I'm using Mongoid to work with MongoDB in Rails.
What I'm looking for is something like active record include. Currently I failed to find such method in mongoid orm.
Anybody know how to solve this problem in mongoid or perhaps in mongomapper, which is known as another good alternative.
...
I would like to know how I can reproduce the following query as map reduce or any juice function from MongoMapper or MongoID:
Event.find(:all,:select=>'events.company,SUM(price) as total_price',
:group=> 'company',:order => ' total_price DESC, created_at DESC')
...
class Comment
include MongoMapper::Document
scope :by_rating, lambda { |minimum| where(:rating.gte => minimum) }
key :rating
belongs_to :user
end
class User
include MongoMapper::Document
many :comments
end
User.first.comments.by_rating(3)
What does the query on last line actually do? Is MongoMapper intelligent enough ...
What is the best way to set up an index or configure a capped collections in a Rails project?
From what I've found, it seems that a good way would be to keep this configuration in an initializer.
The command for setting up an index is ModelName.ensure_index :key, but what is the command for a capped collection?
...
I have an index like this in my database (for my table entries): {"created_at": -1, "search_id": 1, "services":1}
I can make use of that index if I perform a search in the Mongo console like this:
db.entries.find({'search_id':1, 'services':2}).sort({'created_at':
-1})
(if I perform an explain() on that query I can see that it's usi...
If I have:
class Post
include MongoMapper::Document
has_many :comments
end
If I do:
class Comment
include MongoMapper::EmbeddedDocument
belongs_to :post # relevant part
end
Does that create an association using _root_document/_parent_document, or do I have to add the (redundant) key :post_id?
...