heroku WARN --:MONGODB|不支持的客户端选项“raise_not_found_error”,将忽略该选项

332nm8kg  于 2023-04-21  发布在  Go
关注(0)|答案(2)|浏览(94)

我需要在mongoid.yml中设置选项。它在开发中工作,但在heroku中的生产给出了忽略警告消息。有人有经验吗?如何解决这个问题?

W, [2017-04-05T02:04:09.447207 #4]  WARN -- : MONGODB | Unsupported client option 'raise_not_found_error'. It will be ignored.
W, [2017-04-05T02:04:09.449089 #4]  WARN -- : MONGODB | Unsupported client option 'belongs_to_required_by_default'. It will be ignored.
W, [2017-04-05T02:04:09.449176 #4]  WARN -- : MONGODB | Unsupported client option 'consistency'. It will be ignored.

在mongoid.yml中

production:
  clients:
    default:
      uri: <%= ENV['MONGODB_URI'] %>
      options:
        raise_not_found_error: false
        belongs_to_required_by_default: false
        consistency: :strong
a2mppw5e

a2mppw5e1#

这是当Mongo db试图找到任何记录时,它在数据库中不匹配时给出的错误。
在生产配置中添加此行

raise_not_found_error:错误

mongoid.yml
production:
  clients:
    default:
      database: database_name
      hosts:
        - localhost:27017
      options:
        read:
          mode: :primary
        max_pool_size: 1
        raise_not_found_error: false
rsl1atfo

rsl1atfo2#

belongs_to_required_by_default不在clients〉default〉options下。它应该在您的环境下定义:

production:
  clients:
    default:
      uri: <%= ENV['MONGODB_URI'] %>            
  options:
    raise_not_found_error: false
    belongs_to_required_by_default: false

相关问题