Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._database,
pathChild(this.path, id),
Promise.resolve(this.child(id)),
);
}
const pushRef = this.child(id);
const promise = pushRef.set(value, onComplete).then(() => pushRef);
// Prevent unhandled promise rejection if onComplete is passed
if (onComplete) {
promise.catch(() => {});
}
return new DatabaseThenableReference(this._database, pathChild(this.path, id), promise);
}
push(value, onComplete) {
if (!isUndefined(onComplete) && !isFunction(onComplete)) {
throw new Error(
"firebase.database().ref().push(_, *) 'onComplete' must be a function if provided.",
);
}
const id = generateDatabaseId(this._database._serverTimeOffset);
if (isUndefined(value) || isNull(value)) {
return new DatabaseThenableReference(
this._database,
pathChild(this.path, id),
Promise.resolve(this.child(id)),
);
}
const pushRef = this.child(id);
const promise = pushRef.set(value, onComplete).then(() => pushRef);
// Prevent unhandled promise rejection if onComplete is passed
if (onComplete) {
promise.catch(() => {});
}
return new DatabaseThenableReference(this._database, pathChild(this.path, id), promise);
}
child(path) {
if (!isString(path)) {
throw new Error("firebase.database().ref().child(*) 'path' must be a string value.");
}
return new DatabaseReference(this._database, pathChild(this.path, path));
}
child(path) {
const childPath = pathChild(this.path, path);
return new StorageReference(this._storage, childPath);
}