2017-06-30 16:23:32 +00:00
|
|
|
/**
|
|
|
|
* @flow
|
|
|
|
*/
|
2017-11-17 11:07:52 +00:00
|
|
|
import Log from './log';
|
|
|
|
|
|
|
|
import type Database from '../modules/database';
|
|
|
|
import type Storage from '../modules/storage';
|
|
|
|
|
2017-06-30 16:23:32 +00:00
|
|
|
export default class ReferenceBase {
|
2017-11-17 11:07:52 +00:00
|
|
|
_module: Database | Storage;
|
|
|
|
path: string;
|
|
|
|
|
|
|
|
constructor(path: string, module: Database | Storage) {
|
2017-07-12 14:49:33 +00:00
|
|
|
this._module = module;
|
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);
|
|
|
|
}
|
2017-07-12 14:49:33 +00:00
|
|
|
|
2017-11-17 11:07:52 +00:00
|
|
|
get log(): Log {
|
2017-07-12 14:49:33 +00:00
|
|
|
return this._module.log;
|
|
|
|
}
|
2017-06-30 16:23:32 +00:00
|
|
|
}
|