mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 08:42:08 +10:00
Firebase Stub: query parameters not kept between ref calls
This commit is contained in:
@ -78,6 +78,7 @@ class Database {
|
||||
const newRef = new Reference(referencePath, () => this._data);
|
||||
const existingRef = this._references[newRef.path];
|
||||
if (existingRef) {
|
||||
existingRef.initializeQueryParameters();
|
||||
return existingRef;
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,7 @@ class Reference {
|
||||
|
||||
this._getDatabaseData = getDatabaseData;
|
||||
|
||||
this._orderByChildPath = '';
|
||||
this._equalToValue = '';
|
||||
this.initializeQueryParameters();
|
||||
}
|
||||
|
||||
get path() {
|
||||
@ -41,6 +40,14 @@ class Reference {
|
||||
return this._uuid;
|
||||
}
|
||||
|
||||
get orderByChildPath() {
|
||||
return this._orderByChildPath;
|
||||
}
|
||||
|
||||
get equalToValue() {
|
||||
return this._equalToValue;
|
||||
}
|
||||
|
||||
getData() {
|
||||
const databaseData = this._getDatabaseData();
|
||||
|
||||
@ -59,10 +66,10 @@ class Reference {
|
||||
) {
|
||||
data = this.path in databaseData ? databaseData[this.path] : null;
|
||||
|
||||
if (data && this._orderByChildPath && this._equalToValue) {
|
||||
if (data && this.orderByChildPath && this.equalToValue) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(data).filter(
|
||||
([, value]) => value[this._orderByChildPath] === this._equalToValue,
|
||||
([, value]) => value[this.orderByChildPath] === this.equalToValue,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -92,6 +99,11 @@ class Reference {
|
||||
return null;
|
||||
}
|
||||
|
||||
initializeQueryParameters() {
|
||||
this._orderByChildPath = '';
|
||||
this._equalToValue = '';
|
||||
}
|
||||
|
||||
off() {
|
||||
return this !== null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user