我想列出在我的 mongodb 数据库中具有相应集合的所有模型?我正在为 MongoDB 使用 mongoid
gem。
我会尝试这样的事情
ActiveRecord::Base.send :subclasses
效果很好,但我没有使用 ActiveRecord。
最佳答案
有Mongoid::Config#models
:
Get all the models in the application - this is everything that includes
Mongoid::Document
.
所有 Config
方法都可以从 Mongoid
模块中访问,因此您可以调用:
Mongoid.models #=> [...]
https://stackoverflow.com/questions/36891450/
相关文章:
json - 如何使用 Pentaho 从 json 中的三个表到 mongodb 执行复杂文档
node.js - 我的 Electron 应用程序启动时如何启动 mongodb 服务
node.js - 如何使用 mongo/mongoose 连接远程数据库
mongodb - 为启用身份验证的 mongodb 运行 mongostat 时出现问题
mongodb - 如何从 mongodb 集合中删除空字符串?
node.js - Mongoose 在未指定的时间段后停止响应
mongodb - 使用 mongoose 正则表达式与文本在 mongodb 中搜索
node.js - Nodejs 我需要使用 Passport