Mongo.start_link
You're seeing just the function
start_link
, go back to Mongo module for more information.
Specs
start_link(Keyword.t()) :: {:ok, pid()} | {:error, Mongo.Error.t() | atom()}
Start and link to a database connection process.
Options
:database
- The database to use (required):hostname
- The host to connect to (require):port
- The port to connect to your server (default: 27017):url
- A mongo connection url. Can be used in place of:hostname
and:database
(optional):socket_dir
- Connect to MongoDB via UNIX sockets in the given directory. The socket name is derived based on the port. This is the preferred method for configuring sockets and it takes precedence over the hostname. If you are connecting to a socket outside of the MongoDB convection, use:socket
instead.:socket
- Connect to MongoDB via UNIX sockets in the given path. This option takes precedence over:hostname
and:socket_dir
.:database
(optional):seeds
- A list of host names in the cluster. Can be used in place of:hostname
(optional):username
- The User to connect with (optional):password
- The password to connect with (optional):auth
- List of additional users to authenticate as a keyword list with:username
and:password
keys (optional):auth_source
- The database to authenticate against:appname
- The name of the application used the driver for the MongoDB-Handshake:set_name
- The name of the replica set to connect to (required if connecting to a replica set):type
- a hint of the topology type. Seeinitial_type/0
for valid values (default::unknown
):idle
- The idle strategy,:passive
to avoid checkin when idle and:active
to checking when idle (default::passive
):idle_timeout
- The idle timeout to ping the database (default:1_000
):connect_timeout
- The maximum timeout for the initial connection (default:5_000
):backoff_min
- The minimum backoff interval (default:1_000
):backoff_max
- The maximum backoff interval (default:30_000
):backoff_type
- The backoff strategy,:stop
for no backoff and to stop,:exp
of exponential,:rand
for random and:ran_exp
for random exponential (default::rand_exp
):after_connect
- A function to run on connect userun/3
. Either a 1-arity fun,{module, function, args}
withDBConnection.t
, prepended toargs
ornil
(default:nil
):auth_mechanism
- options for the mongo authentication mechanism, currently only supports:x509
atom as a value:ssl
- Set totrue
if ssl should be used (default:false
):ssl_opts
- A list of ssl options, see the ssl docs
Error Reasons
:single_topology_multiple_hosts
- A topology of:single
was set but multiple hosts were given:set_name_bad_topology
- A:set_name
was given but the topology was set to something other than:replica_set_no_primary
or:single