草庐IT

mongoid5

全部标签

ruby-on-rails - Rails - MongoDB(Mongoid)在哪里存储数据库和日志?

我是MongoDB和Mongoid的新手我正在使用Debian测试(jessie/sid)。当我打开/etc/mongodb.conf时,没有关于Mongoid存储数据库和日志的信息。它只是提到了logpath=/var/log/mongodb/mongodb.log同样在config/mongoid.yml中也没有有用的信息:development:sessions:default:hosts:-localhost:27017database:project_development如何在磁盘上找到project_development数据库并记录该数据库的日志?有什么设置吗?

ruby-on-rails - Rails - MongoDB(Mongoid)在哪里存储数据库和日志?

我是MongoDB和Mongoid的新手我正在使用Debian测试(jessie/sid)。当我打开/etc/mongodb.conf时,没有关于Mongoid存储数据库和日志的信息。它只是提到了logpath=/var/log/mongodb/mongodb.log同样在config/mongoid.yml中也没有有用的信息:development:sessions:default:hosts:-localhost:27017database:project_development如何在磁盘上找到project_development数据库并记录该数据库的日志?有什么设置吗?

MongoDB mongoid自引用关系

我是mongo/mongoid的新手,我正在尝试在我的站点表上设置自引用关系。#sitesmodelhas_many:child_sites,:class_name=>'Site'belongs_to:parent,:class_name=>'Site'#controller@event=current_site.child_sites.build(params[:site])current_site是一个返回当前站点对象的函数。我收到此错误-undefinedmethod`entries'for# 最佳答案 您可以尝试将关系定义更

MongoDB mongoid自引用关系

我是mongo/mongoid的新手,我正在尝试在我的站点表上设置自引用关系。#sitesmodelhas_many:child_sites,:class_name=>'Site'belongs_to:parent,:class_name=>'Site'#controller@event=current_site.child_sites.build(params[:site])current_site是一个返回当前站点对象的函数。我收到此错误-undefinedmethod`entries'for# 最佳答案 您可以尝试将关系定义更

ruby-on-rails - 如何只返回 Mongoid 中需要的字段?

如何执行不返回整个文档而只返回我指定的字段的查询? 最佳答案 从马口中:#Returnonlythefirstandlastnamesofeachperson.Person.only(:first_name,:last_name)来源:http://mongoid.org/docs/querying/criteria.html#only 关于ruby-on-rails-如何只返回Mongoid中需要的字段?,我们在StackOverflow上找到一个类似的问题:

ruby-on-rails - 如何只返回 Mongoid 中需要的字段?

如何执行不返回整个文档而只返回我指定的字段的查询? 最佳答案 从马口中:#Returnonlythefirstandlastnamesofeachperson.Person.only(:first_name,:last_name)来源:http://mongoid.org/docs/querying/criteria.html#only 关于ruby-on-rails-如何只返回Mongoid中需要的字段?,我们在StackOverflow上找到一个类似的问题:

mongodb - 如何在 Mongoid 中获取用于调试 map/reduce 的打印输出?

我正在使用Mongoid3.0编写map/reduce操作。我正在尝试使用print语句来调试JS函数。这是troubleshootingsuggestionfromtheMongoDBdocs,例如:reduce=%Q{function(user_id,timestamps){varmax=0;timestamps.forEach(function(t){vardiff=t.started_at-t.attempted_at;if(diff>max){max=diff;}});print(user_id+','+max);returnmax;};}MyCollection.all.m

mongodb - 如何在 Mongoid 中获取用于调试 map/reduce 的打印输出?

我正在使用Mongoid3.0编写map/reduce操作。我正在尝试使用print语句来调试JS函数。这是troubleshootingsuggestionfromtheMongoDBdocs,例如:reduce=%Q{function(user_id,timestamps){varmax=0;timestamps.forEach(function(t){vardiff=t.started_at-t.attempted_at;if(diff>max){max=diff;}});print(user_id+','+max);returnmax;};}MyCollection.all.m

ruby-on-rails - "Not equal"在带有 Mongoid 的 Rails 中命名范围

我有两个模型Content和ContentType。在内容模型中我可以这样做:defget_all_content_except_poking_messageContent.all.where(:name.ne=>"noforking,justpoking")end现在,我正在尝试对ContentType应用范围。再次在内容模型中:#Associationsbelongs_to:content_typedefget_all_content_except_certain_content_type(content_type)Content.all.where(:content_type.n

ruby-on-rails - "Not equal"在带有 Mongoid 的 Rails 中命名范围

我有两个模型Content和ContentType。在内容模型中我可以这样做:defget_all_content_except_poking_messageContent.all.where(:name.ne=>"noforking,justpoking")end现在,我正在尝试对ContentType应用范围。再次在内容模型中:#Associationsbelongs_to:content_typedefget_all_content_except_certain_content_type(content_type)Content.all.where(:content_type.n