mongomapper

Mongo find by regex: return only matching string

家住魔仙堡 提交于 2019-12-04 04:33:58
问题 My application has the following stack: Sinatra on Ruby -> MongoMapper -> MongoDB The application puts several entries in the database. In order to crosslink to other pages, I've added some sort of syntax. e.g.: Coffee is a black, caffeinated liquid made from beans. {Tea} is made from leaves. Both drinks are sometimes enjoyed with {milk} In this example {Tea} will link to another DB entry about tea. I'm trying to query my mongoDB about all 'linked terms'. Usually in ruby I would do something

Unset operation failing for MongoMapper model, cannot delete / remove key from model

淺唱寂寞╮ 提交于 2019-12-04 03:30:14
问题 We're on mongodb 2.0.0, mongo gem 1.4.1, mongo_mapper 0.9.2, rails 3.0.6. We love MongoMapper, but we need helping resolving one nasty issue: we have a key carried over from some testing, but invoking obj.unset fails to do anything. Specifically, we are trying to remove an "id" key (not "_id") because it's causing MM to treat obj.id as different from obj._id, which we don't want. After clearing out the database, we ran these commands from a controller which does nothing else: (We also tried

Advice on migrating from MongoMapper to Mongoid?

岁酱吖の 提交于 2019-12-04 02:45:19
It seems like Mongoid is now the superior ORM for Mongo based on performance and development activity. Unfortunately, we're on MongoMapper and need to migrate. Are there any concerns or stumbling blocks we should be aware of? We have found a few outdated articles on Google and tried posting on the Mongoid Google Groups (though we were prohibited), but would love thoughts from SO members who have done this in the past. We're on Rails 3.2.12. Thanks! Both of them are great MongoDB Libraries for Ruby. But if you want to switch, here are some notes: Migrating MongoMapper ORM to Mongoid ORM - Notes

MongoMapper Parent Inheritance

◇◆丶佛笑我妖孽 提交于 2019-12-03 14:40:08
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 return what I am expecting. >> Item.all => [#<Item name: "Testing", created_at: Sun, 03 Jan 2010 20:02:48 PST -08:00, updated_at: Mon, 04 Jan 2010 13:01:31 PST -08:00, _id: 4b416868010e2a04d0000002, views: 0, user_id: 4b416844010e2a04d0000001, description: "lorem?">] >> Video

Doctrine ODM and schema-less design

女生的网名这么多〃 提交于 2019-12-03 13:40:39
问题 Continuing on from my question about EAV, I'm considering using MongoDB to store product attributes. I will store the catalogue part of this app - Categories, Products and all their related information - with MongoDB (or another document database). My question is, when using an ODM, each entity has a schema, which essentially disregards the schema-less advantage of using a NoSQL database, does it not? If this is correct, why would anyone use an ODM? EDIT: I found a related question, could I

MongoMapper and bson_ext problem

佐手、 提交于 2019-12-03 03:02:41
I can't get MongoMapper to work with my Rails app. I get this error message: **Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance. You can install the extension as follows: gem install bson_ext If you continue to receive this message after installing, make sure that the bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version. I have installed DevKit and installed the gem: gem install bson_ext --no-rdoc --no-ri (result: bson_ext-1.0.1 installed) I'm running on Windows 7. The Rails version is 2.3.7. I used the

mongomapper association skips duplicates

孤街醉人 提交于 2019-12-02 19:43:41
问题 I have a Document with Array of ObjectId: Class Task key :user_id, Array many :userlist, class_name: 'User', :in => :user_id In that Array I store different user_id values, sometimes duplicated. I can see duplicated user_id's using: @task.user_id.each do |z| puts z end But when I fetch and associate the data using: @task.userlist.each do |z| puts z.name end I do not get the duplicates :(, only unique id's get associated. Why? 回答1: What you are seeing is exactly correct from the definition of

Mongomapper many to many issue with Array

a 夏天 提交于 2019-12-02 15:55:57
问题 I would like to list all the task names for the User form the user's tasklist But when I use the code below I get the following message: undefined method `task_id' for ... Here are my classes: class User include MongoMapper::Document key :name, String key :tasklist, Array # I need this to hold ObjIds many :tasks, :in => :tasklist, :class_name => 'Task' def add(taskid) a = self.new a.task_id << taskid a.save end class Task include MongoMapper::Document key :name, String many :users end 回答1: I

Mongomapper many to many issue with Array

泄露秘密 提交于 2019-12-02 10:00:53
I would like to list all the task names for the User form the user's tasklist But when I use the code below I get the following message: undefined method `task_id' for ... Here are my classes: class User include MongoMapper::Document key :name, String key :tasklist, Array # I need this to hold ObjIds many :tasks, :in => :tasklist, :class_name => 'Task' def add(taskid) a = self.new a.task_id << taskid a.save end class Task include MongoMapper::Document key :name, String many :users end I used: a = self.new a.tasklist = [object1,object2] a.save Then I can iterate through all the object

mongodb and mongomapper

社会主义新天地 提交于 2019-12-02 09:39:10
问题 i have a rails app that currently uses activerecord to store and query products. Each product has a category and sub category and each sub category is defined by multiple field that i can create within the application. From this when a user wants to input a specific product, they are pressented with the relevent form fields. This has become very complex and having since hearing about mongodb and mongomapper, i think or wish i created it from the start in using mongomapper !!! Problem is i