src/back/MongoAdapter.js
function getDatabase() {
    var mongoAdapter = this;

    expect(arguments).to.have.length(
      0,
      'Invalid arguments length when getting a database in a MongoAdapter ' +
      '(it has to be passed no arguments)'
    );

    return new Promise(function (resolve, reject) {
      if (_databaseIsLocked || !_database) {
        mongoAdapter
          .openConnection()
          .then(function () {
            resolve(_database);
          })
          .catch(reject);
      } else {
        resolve(_database);
      }
    });
  }
function getDatabase() {
    var mongoAdapter = this;

    expect(arguments).to.have.length(
      0,
      'Invalid arguments length when getting a database in a MongoAdapter ' +
      '(it has to be passed no arguments)'
    );

    return new Promise(function (resolve, reject) {
      if (_databaseIsLocked || !_database) {
        mongoAdapter
          .openConnection()
          .then(function () {
            resolve(_database);
          })
          .catch(reject);
      } else {
        resolve(_database);
      }
    });
  }
function getDatabase ( ) { var mongoAdapter = this ; expect ( arguments ) . to . have . length ( 0 , 'Invalid arguments length when getting a database in a MongoAdapter ' + '(it has to be passed no arguments)' ) ; return new Promise ( function ( resolve , reject ) { if ( _databaseIsLocked || ! _database ) { mongoAdapter . openConnection ( ) . then ( function ( ) { resolve ( _database ) ; } ) . catch ( reject ) ; } else { resolve ( _database ) ; } } ) ; }
Gets the MongoClient Db object to be use to perform the operations.
@name module:back4app-entity-mongodb.MongoAdapter#getDatabase
@function
@returns {Promise.<Db|Error>} Promise that returns the MongoClient Db
object if succeed and the Error if failed.
@example
mongoAdapter.getDatabase()
.then(function (database) {
database.createCollection('myCollection');
})
.catch(function (error) {
console.log(error);
});
Gets the MongoClient Db object to be use to perform the operations .