mongoose#ConnectionOptions TypeScript Examples

The following examples show how to use mongoose#ConnectionOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoDB.ts    From Asena with MIT License 6 votes vote down vote up
constructor(options: ConnectionOptions = {
        useNewUrlParser: true,
        useCreateIndex: true,
        useFindAndModify: false,
        useUnifiedTopology: true
    }){
        this.options = options

        // event listeners
        mongoose.connection.on('open', () => {
            this.logger.info('Database connection has been established successfully.')

            this.setConnected(true)

            mongoose.connection.db.admin().serverInfo().then(obj => {
                MongoDB.serverInfo = obj
            })
        })

        mongoose.connection.on('disconnected', () => {
            this.logger.info('Database connection disconnected.')

            this.setConnected(false)
        })

        mongoose.connection.on('error', err => {
            this.logger.error('Database connection error: ' + err)
        })
    }
Example #2
Source File: MongoDB.ts    From Asena with MIT License 5 votes vote down vote up
private readonly options: ConnectionOptions