我无法在mongodb版本3.0.12
中执行upsert查询,而ruby gem版本为1.x
。我使用ruby版本1.9.3。我尝试将mongodb升级到版本3.2
和3.4
,但仍面临同样的问题。如果有人知道发生了什么或遇到类似的问题,请提供一些见解。
Database command 'update' failed: Unknown option to update command: upsert
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/db.rb:559:in `rescue in command'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/db.rb:555:in `command'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/collection_writer.rb:314:in `block in send_write_command'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/functional/logging.rb:55:in `block in instrument'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/functional/logging.rb:20:in `instrument'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/functional/logging.rb:54:in `instrument'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/collection_writer.rb:313:in `send_write_command'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/collection.rb:1076:in `send_write'
/Users/ayushgaur/.rvm/gems/ruby-1.9.3-p551/bundler/gems/mongo-ruby-driver-de949571b660/lib/mongo/collection.rb:497:in `update'
答案 0 :(得分:0)
mongo-ruby-driver 1.x根据https://www.mongodb.com/blog/post/announcing-ruby-driver-20-rewrite不完全支持mongodb 3:
升级到mongo gem版本2.0和mongoid gem版本5.0有很多原因,当它发布时。首先,这些版本支持MongoDB 3.0 [...] 不会添加新功能,开发工作将仅包含错误修复和支持最新版本服务器所需的最少功能。
我在整个互联网上搜索了有类似问题的人,我发现的唯一的人是pagerbot,他们使用1.x系列的gem和mongo 3并得到与你完全相同的错误:
https://github.com/stripe-contrib/pagerbot/issues/46
他们通过更新到mongo-ruby-driver解决了这个错误.2。为了让你与这些依赖关系搏斗而道歉,但我找不到更简单的答案。