diff --git a/lib/modules/database/reference.js b/lib/modules/database/reference.js index 0c4dfef6..9137767f 100644 --- a/lib/modules/database/reference.js +++ b/lib/modules/database/reference.js @@ -262,13 +262,11 @@ export default class Reference extends ReferenceBase { if (_failureCallback) { _failureCallback = (error) => { if (error.message.startsWith('FirebaseError: permission_denied')) { - - error.message = `permission_denied at /${this.path}: Client doesn\'t have permission to access the desired data.` + error.message = `permission_denied at /${this.path}: Client doesn't have permission to access the desired data.` } failureCallbackOrContext(error); - - } + }; } let _successCallback; @@ -375,11 +373,9 @@ export default class Reference extends ReferenceBase { * @param onComplete * @param applyLocally */ - transaction( - transactionUpdate: Function, - onComplete: (error: ?Error, committed: boolean, snapshot: ?Snapshot) => *, - applyLocally: boolean = false - ) { + transaction(transactionUpdate: Function, + onComplete: (error: ?Error, committed: boolean, snapshot: ?Snapshot) => *, + applyLocally: boolean = false) { if (!isFunction(transactionUpdate)) { return Promise.reject( new Error('Missing transactionUpdate function argument.') @@ -588,7 +584,7 @@ export default class Reference extends ReferenceBase { * * {@link https://firebase.google.com/docs/reference/js/firebase.database.Reference#parent} */ - get parent(): Reference|null { + get parent(): Reference | null { if (this.path === '/') return null; return new Reference(this.database, this.path.substring(0, this.path.lastIndexOf('/'))); } diff --git a/lib/modules/database/snapshot.js b/lib/modules/database/snapshot.js index 9abb6b01..6a117104 100644 --- a/lib/modules/database/snapshot.js +++ b/lib/modules/database/snapshot.js @@ -17,9 +17,14 @@ export default class Snapshot { _childKeys: Array; constructor(ref: Reference, snapshot: Object) { - this.ref = ref; this.key = snapshot.key; + if (ref.key !== snapshot.key) { + this.ref = ref.child(snapshot.key); + } else { + this.ref = ref; + } + // internal use only this._value = snapshot.value; this._priority = snapshot.priority === undefined ? null : snapshot.priority;