diff --git a/lib/index.js b/lib/index.js index e62a3a56f77..db353d5e448 100644 --- a/lib/index.js +++ b/lib/index.js @@ -122,6 +122,15 @@ Mongoose.prototype.cast = cast; Mongoose.prototype.STATES = STATES; /** + * Expose connection states for user-land + * + * @memberOf Mongoose + * @property ConnectionStates + * @api public + */ +Mongoose.prototype.ConnectionStates = STATES; + + /** * Object with `get()` and `set()` containing the underlying driver this Mongoose instance * uses to communicate with the database. A driver is a Mongoose-specific interface that defines functions * like `find()`. diff --git a/test/typescript/global.ts b/test/typescript/global.ts index 4700a41a071..6dc65f058c6 100644 --- a/test/typescript/global.ts +++ b/test/typescript/global.ts @@ -3,6 +3,7 @@ import mongoose from 'mongoose'; const m: mongoose.Mongoose = new mongoose.Mongoose(); m.STATES.connected; +m.ConnectionStates.connected; m.connect('mongodb://localhost:27017/test').then(() => { console.log('Connected!');