mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-05-04 09:41:43 +08:00
js: change db error to match firebase web sdk error
This commit is contained in:
@@ -77,12 +77,12 @@ export default class Reference extends ReferenceBase {
|
||||
*/
|
||||
push(value: any, onComplete: Function) {
|
||||
if (value === null || value === undefined) {
|
||||
const _path = this.path + '/' + generatePushID(this.db.serverTimeOffset);
|
||||
return new Reference(this.db, _path);
|
||||
return new Reference(this.db, `${this.path}/${generatePushID(this.db.serverTimeOffset)}`);
|
||||
}
|
||||
|
||||
const path = this._dbPath();
|
||||
const _value = this._serializeAnyType(value);
|
||||
|
||||
return promisify('push', FirebaseDatabase)(path, _value)
|
||||
.then(({ ref }) => {
|
||||
const newRef = new Reference(this.db, ref);
|
||||
@@ -102,7 +102,7 @@ export default class Reference extends ReferenceBase {
|
||||
* @param context TODO
|
||||
* @returns {*}
|
||||
*/
|
||||
on(eventType: string, successCallback: () => any, failureCallback: () => any, context) {
|
||||
on(eventType: string, successCallback: () => any, failureCallback: () => any) {
|
||||
if (!isFunction(successCallback)) throw new Error('The specified callback must be a function');
|
||||
if (failureCallback && !isFunction(failureCallback)) throw new Error('The specified error callback must be a function');
|
||||
const path = this._dbPath();
|
||||
@@ -280,14 +280,27 @@ export default class Reference extends ReferenceBase {
|
||||
return newRef;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Disconnect}
|
||||
*/
|
||||
onDisconnect() {
|
||||
return new Disconnect(this.path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specified child
|
||||
* @param path
|
||||
* @returns {Reference}
|
||||
*/
|
||||
child(path: string) {
|
||||
return new Reference(this.db, this.path + '/' + path);
|
||||
return new Reference(this.db, `${this.path}/${path}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ref as a path string
|
||||
* @returns {string}
|
||||
*/
|
||||
toString(): string {
|
||||
return this._dbPath();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user