【问题标题】:Indices and capped collections with MongoMapper使用 MongoMapper 的索引和上限集合
【发布时间】:2010-10-17 21:59:50
【问题描述】:

在 Rails 项目中设置索引或配置上限集合的最佳方法是什么?

根据我的发现,将这个配置保存在初始化器中似乎是一个好方法。

设置索引的命令是ModelName.ensure_index :key,那么设置上限集合的命令是什么?

【问题讨论】:

    标签: ruby-on-rails indexing mongodb mongomapper


    【解决方案1】:

    只需下拉到 ruby​​ 驱动程序即可创建集合。

    http://api.mongodb.org/ruby/1.0.7/Mongo/DB.html#create_collection-instance_method

    Foo.database.create_collection(:foo, :capped => true)
    

    在初始化程序或其他东西中执行此操作。

    【讨论】:

      猜你喜欢
      • 2016-06-22
      • 1970-01-01
      • 1970-01-01
      • 2015-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 1970-01-01
      相关资源
      最近更新 更多