react-native-firebase/lib/utils/ReferenceBase.js

21 lines
527 B
JavaScript
Raw Normal View History

/**
* @flow
*/
export default class ReferenceBase {
constructor(path: string) {
this.path = path || '/';
}
// todo add missing firebase reference props/methods
/**
* 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);
}
}