Mongomapper 使用名称引用数据库导致 ReferenceError 问题
这是 Mongomapper 生成的查询:
MONGODB mydatabase['users'].find({:name=>"bob"}).limit(-1)
但这在 mongo 控制台中无效,因为正确的语法是
db.users.find({:name=>"bob"}).limit(-1)
如果我只使用生成的语法,我在控制台中收到此错误
Thu Jan 12 03:01:23 ReferenceError: mydatabase is not defined (shell):1
有什么方法可以使其正确吗?这导致我的 Rails 应用程序损坏。
This is the query generated by Mongomapper:
MONGODB mydatabase['users'].find({:name=>"bob"}).limit(-1)
But this is not valid in the mongo console since the correct syntax is
db.users.find({:name=>"bob"}).limit(-1)
If I just use the generated one, I got this error in the console
Thu Jan 12 03:01:23 ReferenceError: mydatabase is not defined (shell):1
Is there any way to make it correct? This causes my rails application broken.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能在 MongoDB 控制台中使用符号,因为它们是 ruby 而不是 javascript :-) 试试这个:
You can't use symbols in the MongoDB console as they are ruby and not javascript :-) Try this:
这不是mongodb的问题。 406 与控制器调用密切相关。
我需要使用:
而不是
It is not mongodb's issue. 406 is pretty much relating to the controller call.
I need to use:
rather than