22 lines
507 B
JavaScript
22 lines
507 B
JavaScript
/**
|
|
* @flow
|
|
*/
|
|
|
|
// todo move out
|
|
export class ReferenceBase extends Base {
|
|
constructor(path: string) {
|
|
super();
|
|
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 {
|
|
return this.path === '/' ? null : this.path.substring(this.path.lastIndexOf('/') + 1);
|
|
}
|
|
}
|