@@ -106,26 +106,24 @@ block content
106106
107107 h4#connection-string-options Connection String Options
108108 :markdown
109- Mongoose supports the following options in the connection string.
110-
111- * [ssl](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
112- * [poolSize](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
113- * [autoReconnect](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
114- * [socketTimeoutMS](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
115- * [connectTimeoutMS](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
116- * [authSource](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
117- * [retries](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
118- * [authMechanism](http://mongodb.github.io/node-mongodb-native/2.2/tutorials/connect/authenticating/)
119- * [reconnectWait](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
120- * [rs_name](http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html)
121- * [replicaSet](http://mongodb.github.io/node-mongodb-native/2.1/api/ReplSet.html)
122- * [nativeParser](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
123- * [w](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
124- * [journal](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
125- * [wtimeoutMS](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
126- * [readPreference](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
127- * [readPreferenceTags](http://mongodb.github.io/node-mongodb-native/2.1/api/Db.html)
128- * [sslValidate](http://mongodb.github.io/node-mongodb-native/2.1/api/Server.html)
109+ You can also specify options in your connection string as [parameters in the query string](https://en.wikipedia.org/wiki/Query_string) portion of the URI.
110+ :js
111+ mongoose.connect('mongodb://localhost:27017/test?connectTimeoutMS=1000', { useMongoClient: true });
112+ // The above is equivalent to:
113+ mongoose.connect('mongodb://localhost:27017/test', {
114+ useMongoClient: true,
115+ connectTimeoutMS: 1000
116+ });
117+ :markdown
118+ The disadvantage of putting options in the query string is that query
119+ string options are harder to read. The advantage is that you only need a
120+ single configuration option, the URI, rather than separate options for
121+ `socketTimeoutMS`, `connectTimeoutMS`, etc. Best practice is to put options
122+ that likely differ between development and production, like `replicaSet`
123+ or `ssl`, in the connection string, and options that should remain constant,
124+ like `connectTimeoutMS` or `poolSize`, in the options object.
125+
126+ The MongoDB docs have a full list of [supported connection string options](https://docs.mongodb.com/manual/reference/connection-string/)
129127
130128 h4#keepAlive A note about keepAlive
131129 .important
0 commit comments