繁体   English   中英

Ruby和MongoDB-检索数据库和集合

[英]Ruby and MongoDB - Retrieve Database and Collections

从我的Rails应用程序中,如何检索与其连接的MongoDB数据库(及其集合)?

请注意,我不想列出数据库。 我只需要一个应用程序连接到的那个!

  • 您可能应该使用ODM: https//github.com/mongodb/mongoid
  • 按照此处设置config / mongoid.yml。
  • 在模型中include Mongoid::Document
  • 之后,您可以按照Rails方式查询〜 results = Foo.where(name: "bar")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM