2017-06-30 16:23:32 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
*/
|
|
|
|
export default class ReferenceBase {
|
2017-11-17 11:07:52 +00:00
|
|
|
path: string;
|
|
|
|
|
2018-01-05 17:20:02 +00:00
|
|
|
constructor(path: string) {
|
2017-06-30 16:23:32 +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 {
|
|
|
|
return this.path === '/' ? null : this.path.substring(this.path.lastIndexOf('/') + 1);
|
|
|
|
}
|
|
|
|
}
|