lib/rails/generators/mongoid/config/templates/mongoid.yml
development:
# Configure available database clients. (required)
clients:
# Defines the default client. (required)
default:
# Mongoid can connect to a URI accepted by the driver:
# uri: mongodb://user:password@mongodb.domain.com:27017/<%= database_name || app_name %>_development
# Otherwise define the parameters separately.
# This defines the name of the default database that Mongoid can connect to.
# (required).
database: <%= database_name || app_name %>_development
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost:27017
options:
# Note that all options listed below are Ruby driver client options (the mongo gem).
# Please refer to the driver documentation of the version of the mongo gem you are using
# for the most up-to-date list of options.
# Change the default write concern. (default = { w: 1 })
# write:
# w: 1
# Change the default read preference. Valid options for mode are: :secondary,
# :secondary_preferred, :primary, :primary_preferred, :nearest
# (default: primary)
# read:
# mode: :secondary_preferred
# tag_sets:
# - use: web
# The name of the user for authentication.
# user: 'user'
# The password of the user for authentication.
# password: 'password'
# The user's database roles.
# roles:
# - 'dbOwner'
# Change the default authentication mechanism. Valid options include:
# :scram, :scram256, :mongodb_cr, :mongodb_x509, :gssapi, :aws, :plain.
# MongoDB Server defaults to :scram, which will use "SCRAM-SHA-256" if available,
# otherwise fallback to "SCRAM-SHA-1" (:scram256 will always use "SCRAM-SHA-256".)
# This setting is handled by the MongoDB Ruby Driver. Please refer to:
# https://mongodb.com/docs/ruby-driver/current/reference/authentication/
# auth_mech: :scram
# The database or source to authenticate the user against.
# (default: the database specified above or admin)
# auth_source: admin
# Force the driver cluster to behave in a certain manner instead of auto-discovering.
# Can be one of: :direct, :replica_set, :sharded. Set to :direct
# when connecting to hidden members of a replica set.
# connect: :direct
# Changes the default time in seconds the server monitors refresh their status
# via hello commands. (default: 10)
# heartbeat_frequency: 10
# The time in seconds for selecting servers for a near read preference. (default: 0.015)
# local_threshold: 0.015
# The timeout in seconds for selecting a server for an operation. (default: 30)
# server_selection_timeout: 30
# The maximum number of connections in the connection pool. (default: 5)
# max_pool_size: 5
# The minimum number of connections in the connection pool. (default: 1)
# min_pool_size: 1
# The time to wait, in seconds, in the connection pool for a connection
# to be checked in before timing out. (default: 5)
# wait_queue_timeout: 5
# The time to wait to establish a connection before timing out, in seconds.
# (default: 10)
# connect_timeout: 10
# How long to wait for a response for each operation sent to the
# server. This timeout should be set to a value larger than the
# processing time for the longest operation that will be executed
# by the application. Note that this is a client-side timeout;
# the server may continue executing an operation after the client
# aborts it with the SocketTimeout exception.
# (default: nil, meaning no timeout)
# socket_timeout: 5
# The name of the replica set to connect to. Servers provided as seeds that do
# not belong to this replica set will be ignored.
# replica_set: name
# Compressors to use for wire protocol compression. (default is to not use compression)
# "zstd" requires zstd-ruby gem. "snappy" requires snappy gem.
# Refer to: https://www.mongodb.com/docs/ruby-driver/current/reference/create-client/#compression
# compressors: ["zstd", "snappy", "zlib"]
# Whether to connect to the servers via ssl. (default: false)
# ssl: true
# The certificate file used to identify the connection against MongoDB.
# ssl_cert: /path/to/my.cert
# The private keyfile used to identify the connection against MongoDB.
# Note that even if the key is stored in the same file as the certificate,
# both need to be explicitly specified.
# ssl_key: /path/to/my.key
# A passphrase for the private key.
# ssl_key_pass_phrase: password
# Whether to do peer certification validation. (default: true)
# ssl_verify: true
# The file containing concatenated certificate authority certificates
# used to validate certs passed from the other end of the connection.
# ssl_ca_cert: /path/to/ca.cert
# Whether to truncate long log lines. (default: true)
# truncate_logs: true
# Configure Mongoid-specific options. (optional)
options:
<%- Mongoid::Config::Introspection.options.each do |opt| -%>
<%= opt.indented_comment(indent: 4) %>
# <%= opt.name %>: <%= opt.default %>
<%- end -%>
# Configure Driver-specific options. (optional)
driver_options:
# When this flag is off, an aggregation done on a view will be executed over
# the documents included in that view, instead of all documents in the
# collection. When this flag is on, the view fiter is ignored.
# broken_view_aggregate: true
# When this flag is set to false, the view options will be correctly
# propagated to readable methods.
# broken_view_options: true
# When this flag is set to true, the update and replace methods will
# validate the paramters and raise an error if they are invalid.
# validate_update_replace: false
test:
clients:
default:
database: <%= database_name || app_name %>_test
hosts:
- localhost:27017
options:
read:
mode: :primary
max_pool_size: 1