How to query MongoDB directly from Ruby instead of using Mongoid?

前端 未结 7 461
刺人心
刺人心 2020-12-24 06:33

I am writing a migration for a Rails application that uses MongoDB and Mongoid. My migration currently uses my models that use Mongoid to query and update records, but the p

7条回答
  •  眼角桃花
    2020-12-24 07:10

    For Mongoid 5:

    db = Mongoid::Clients.default
    
    collection = db[:collection_name]
    

    Now we can perform queries on the collection

提交回复
热议问题