react-native-firebase/lib/modules/base.js

22 lines
507 B
JavaScript
Raw Normal View History

2017-03-02 13:10:10 +00:00
/**
* @flow
*/
// todo move out
2017-03-02 13:10:10 +00:00
export class ReferenceBase extends Base {
constructor(path: string) {
super();
2017-03-02 13:10:10 +00:00
this.path = path || '/';
}
/**
* The last part of a Reference's path (after the last '/')
* The key of a root Reference is null.
* @type {String}
* {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference#key}
*/
get key(): string | null {
2017-03-02 13:10:10 +00:00
return this.path === '/' ? null : this.path.substring(this.path.lastIndexOf('/') + 1);
}
}