Class: FirebaseAccount

FirebaseAccount

new FirebaseAccount(adminToken)

Creates a new reference to a Firebase account.

Parameters:
Name Type Description
adminToken String

The admin token for the account.

Source:

Methods

<static> bootstrapInstance(email, password) → {external:Promise}

Promises to create a new Firebase instance under the account with the specified username and password. A convenience method.

Parameters:
Name Type Description
email String

The email address associated with the account.

password String

The password for the account.

Source:
Returns:

A promise that resolves with a FirebaseInstance if successful and rejects with an Error if there's an error. This instance also has an extra method, tearDown, that deletes the database.

Type
external:Promise
Example
FirebaseAccount.bootstrapInstance('token')
.then(function(db) {
  // get a Firebase reference to the new instance
  var fb = new   Firebase(db.toString());
  fb.child('spam/spam/spam/spam').set('wonderful');
}, function(err) {
  console.error('Error while creating new instance:', err);
});

createDatabase(name) → {external:Promise}

Promises to create a new Firebase instance under the account.

Parameters:
Name Type Description
name String

The name of the new instance.

Source:
Returns:

A promise that resolves with a FirebaseInstance if successful and rejects with an Error if there's an error.

Type
external:Promise
Example
account.createDatabase('newfirebase')
.then(function(db) {
  // get a Firebase reference to the new instance
  var fb = new Firebase(db.toString());
  fb.child('spam/spam/spam/spam').set('wonderful');
})
.catch(function(err) {
  console.error('Error while creating new instance:', err);
});

deleteDatabase(db) → {external:Promise}

Promises to remove a Firebase instance from the account

Parameters:
Name Type Description
db FirebaseInstance

The instance to remove.

Source:
Returns:

A promise that resolves if db is deleted successfully and rejects with an Error if there's an error.

Type
external:Promise

getDatabase(name) → {external:Promise}

Promises to retrieve a new Firebase instance under the account.

Parameters:
Name Type Description
name String

The name of the instance.

Source:
Returns:

A promise that resolves with a FirebaseInstance if successful and rejects with an Error if there's an error.

Type
external:Promise
Example
account.getDatabase('existingfirebase')
.then(function(db) {
  // get a Firebase reference to the instance
  var fb = new Firebase(db.toString());
  fb.child('spam/spam/spam/spam').on('value', function(snap) {
    console.log(snap.val(), 'spam, lovely spam');
  });
})
.catch(function(err) {
  console.error('Error retrieving instance:', err);
});