2017-03-02 13:10:10 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
|
2017-06-29 16:24:34 +00:00
|
|
|
// todo move out
|
2017-03-02 13:10:10 +00:00
|
|
|
export class ReferenceBase extends Base {
|
2017-05-26 16:55:22 +00:00
|
|
|
constructor(path: string) {
|
|
|
|
super();
|
2017-03-02 13:10:10 +00:00
|
|
|
this.path = path || '/';
|
|
|
|
}
|
|
|
|
|
2017-05-06 13:33:55 +00:00
|
|
|
/**
|
|
|
|
* 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}
|
|
|
|
*/
|
2017-06-29 16:24:34 +00:00
|
|
|
get key(): string | null {
|
2017-03-02 13:10:10 +00:00
|
|
|
return this.path === '/' ? null : this.path.substring(this.path.lastIndexOf('/') + 1);
|
|
|
|
}
|
|
|
|
}
|