Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #11 from davideast/getKey
Browse files Browse the repository at this point in the history
fix(key): Change key() to getKey()
  • Loading branch information
davideast committed Jun 6, 2016
2 parents d84e7f8 + 7254136 commit 170f1cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/querybase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ class Querybase {

// read only properties

// Returns a read-only Firebase reference
// Returns a read-only Database reference
ref: () => Firebase;
// Returns a read-only set of indexes
indexOn: () => string[];
// the key of the Firebase ref
key: () => string;
// the key of the Database ref
getKey: () => string;
// the set of indexOn keys base64 encoded
private encodedKeys: () => string[];

Expand All @@ -223,7 +223,7 @@ class Querybase {
this.ref = () => ref;
this.indexOn = () => indexOn;
/* istanbul ignore next */
this.key = () => this.ref().key();
this.getKey = () => this.ref().getKey();
this.encodedKeys = () => this.encodeKeys(this.indexOn());
}

Expand Down
10 changes: 10 additions & 0 deletions tests/unit/querybase.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ describe('Querybase', () => {

});

describe('getKey', () => {

it('should throw if no indexes are provided', () => {
const querybaseRef = querybase.ref(ref, ['name', 'age']);
const key = querybaseRef.getKey();
assert.equal(key, 'items');
});

});

describe('set', () => {

it('should call the Firebase set function', () => {
Expand Down
4 changes: 2 additions & 2 deletions typings/firebase/firebase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface FirebaseDataSnapshot {
/**
* Gets the key name of the location that generated this DataSnapshot.
*/
key(): string;
getKey(): string;
/**
* @deprecated Use key() instead.
* Gets the key name of the location that generated this DataSnapshot.
Expand Down Expand Up @@ -238,7 +238,7 @@ interface Firebase extends FirebaseQuery {
/**
* Returns the last token in a Firebase location.
*/
key(): string;
getKey(): string;
/**
* @deprecated Use key() instead.
* Returns the last token in a Firebase location.
Expand Down

0 comments on commit 170f1cf

Please sign in to comment.