mongoid3

    2熱度

    3回答

    我有一個數組的文檔文件: { _id: ObjectId("515e10784903724d72000003"), association_chain: [ { name: "Product", id: ObjectId("4e1e2cdd9a86652647000003") } ], //... }

    1熱度

    1回答

    不知道這一個Mongoid具體的事情,或者適用於更大的活動記錄模式。 我有下面的代碼塊,它的工作原理: submission.reload.profile submission.milestone = self.milestone submission.profile = @profile @profile.save && submission.save 的關係得到正確更新。但是,如果我

    0熱度

    1回答

    有沒有更好的方式來做到這一點? class User embeds_many :groups def group(group_id) gid = Moped::BSON::ObjectId(group_id) self.groups.each.detect{|group| group.id == gid} end end class G

    0熱度

    1回答

    最近從3.0.3更新到Mongoid 3.1,這導致了一些破碎的代碼和混淆在我身邊。 假設你有一對類有belongs_to的/的has_many關係,就像這樣: class Band include Mongoid::Document field :name, type: String has_many :members, :autosave => true end

    0熱度

    1回答

    我遇到了使用Mongoid的grouped_collection_select問題。我得到的錯誤消息是:ActionView :: Template :: Error(未定義的方法`合併':name:Symbol)。 我正在使用rails 3.2.12 &最新版本的Mongoid。 這裏是我的代碼: class States include Mongoid::Document

    1熱度

    1回答

    在mongodb中使用mongoid驅動程序做Model.find(array_of_ids)性能差,我不明白爲什麼。 相關代碼: ids = get_ids() #Get an array of 137 _ids for Topic model. Topic.find(ids) #Find all data, but take 4 seconds to do it. _id字段的自動索引,

    0熱度

    1回答

    我用MongoDB創建了一個樣本數據庫,其中包含來自MongoDB網站上JSON文件的數據 我已經用以下命令導入了它。 mongoimport --db test --collection zips --file zips.json 數據正在處理中,當我嘗試在控制檯中搜索數據時,它會顯示出來,到目前爲止非常好。 我的問題是當我試圖用我的Rails應用程序使用數據庫。我創建了一個Class,City

    2熱度

    1回答

    我需要從數據庫中選擇一個隨機文檔,並且想知道比大型數據庫資源密集度較低的Ruby shuffle方法更好的策略。

    2熱度

    1回答

    我有一個簡單的使用Rails和Mongoid ORM的博客引擎。 我在博客中有兩個模型,'Article'和'Url'。 Article模型包含所有帖子內容,Url類是生成器函數,它接收文章的slu and併爲其創建一個Short URL。 E.g. 我的樣本 - 博客 - 後 - >ai3n等等,等等 的問題是我有鏈接的兩個問題。我無法將URL類嵌入到Article類中。 我的問題是,當文章模型

    0熱度

    1回答

    我目前正在使用mongoid和rails進行項目。下面是代碼: class Account include Mongoid::Document include Mongoid::Timestamps field :account_name, type: String has_many :groups end class Group inc