Skip to content

Commit

Permalink
docs(mongoose): document mongoose.connections
Browse files Browse the repository at this point in the history
Fix #7338
  • Loading branch information
vkarpov15 committed Jan 10, 2019
1 parent ea3f10b commit 33f6aa1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/api.jade
Expand Up @@ -58,6 +58,10 @@ block content
h5 Returns:
ul
li <span class="method-type">&laquo;#{prop.return.types}&raquo;</span> !{prop.return.description}
if prop.type != null
h5 Type:
ul
li <span class="method-type">&laquo;#{prop.type}&raquo;</span>
div
| !{prop.description}

Expand Down
8 changes: 7 additions & 1 deletion docs/source/api.js
Expand Up @@ -70,7 +70,13 @@ function parse() {
break;
case 'property':
ctx.type = 'property';
ctx.name = tag.string;
let str = tag.string;
const match = str.match(/^{\w+}/);
if (match != null) {
ctx.type = match[0].substring(1, match[0].length - 1);
str = str.replace(/^{\w+}\s*/, '');
}
ctx.name = str;
ctx.string = `${ctx.constructor}.prototype.${ctx.name}`;
break;
case 'static':
Expand Down
30 changes: 27 additions & 3 deletions lib/index.js
Expand Up @@ -586,7 +586,7 @@ Mongoose.prototype.plugin = function(fn, opts) {
};

/**
* The default connection of the mongoose module.
* The Mongoose module's default connection. Equivalent to `mongoose.connections][0]`, see [`connections`](#mongoose_Mongoose-connections).
*
* ####Example:
*
Expand All @@ -596,10 +596,11 @@ Mongoose.prototype.plugin = function(fn, opts) {
*
* This is the connection used by default for every model created using [mongoose.model](#index_Mongoose-model).
*
* To create a new connection, use [`createConnection()`](#mongoose_Mongoose-createConnection).
*
* @memberOf Mongoose
* @instance
* @property connection
* @return {Connection}
* @property {Connection} connection
* @api public
*/

Expand All @@ -614,6 +615,29 @@ Mongoose.prototype.__defineSetter__('connection', function(v) {
}
});

/**
* An array containing all [connections](connections.html) associated with this
* Mongoose instance. By default, there is 1 connection. Calling
* [`createConnection()`](#mongoose_Mongoose-createConnection) adds a connection
* to this array.
*
* ####Example:
*
* const mongoose = require('mongoose');
* mongoose.connections.length; // 1, just the default connection
* mongoose.connections[0] === mongoose.connection; // true
*
* mongoose.createConnection('mongodb://localhost:27017/test');
* mongoose.connections.length; // 2
*
* @memberOf Mongoose
* @instance
* @property {Array} connections
* @api public
*/

Mongoose.prototype.connections;

/*!
* Driver dependent APIs
*/
Expand Down

0 comments on commit 33f6aa1

Please sign in to comment.