Firebase query not returning results everytime it runsHow can I get query string values in JavaScript?event.preventDefault() vs. return falseReturn multiple values in JavaScript?Why does ++[[]][+[]]+[+[]] return the string “10”?Why does parseInt(1/0, 19) return 18?Is Safari on iOS 6 caching $.ajax results?How do I return the response from an asynchronous call?Is it safe to expose Firebase apiKey to the public?Querying Firebase with Angular to get document keysWhy can't I get the alert to show?
Is `x >> pure y` equivalent to `liftM (const y) x`
How to Reset Passwords on Multiple Websites Easily?
What is paid subscription needed for in Mortal Kombat 11?
Is a stroke of luck acceptable after a series of unfavorable events?
Go Pregnant or Go Home
What is the difference between "behavior" and "behaviour"?
Customer Requests (Sometimes) Drive Me Bonkers!
System.debug(JSON.Serialize(o)) Not longer shows full string
Opposite of a diet
How does buying out courses with grant money work?
What is the opposite of 'gravitas'?
How do I find the solutions of the following equation?
How to check is there any negative term in a large list?
Detecting if an element is found inside a container
Escape a backup date in a file name
Two monoidal structures and copowering
Applicability of Single Responsibility Principle
How to write papers efficiently when English isn't my first language?
Integer addition + constant, is it a group?
Trouble understanding the speech of overseas colleagues
Why are there no referendums in the US?
Type int? vs type int
Do the temporary hit points from Reckless Abandon stack if I make multiple attacks on my turn?
when is out of tune ok?
Firebase query not returning results everytime it runs
How can I get query string values in JavaScript?event.preventDefault() vs. return falseReturn multiple values in JavaScript?Why does ++[[]][+[]]+[+[]] return the string “10”?Why does parseInt(1/0, 19) return 18?Is Safari on iOS 6 caching $.ajax results?How do I return the response from an asynchronous call?Is it safe to expose Firebase apiKey to the public?Querying Firebase with Angular to get document keysWhy can't I get the alert to show?
I have implemented a search function in an angular 7 app that uses Firebase. I want the user to provide a from and to values always and a date value optionally. At the moment whenever a user provides all 3 values (from, to & date) the query returns the expected result. But if only from & to values are provided, the query returns expected result sometimes and doesn't at other times. I haven't been able to find a bug in my code so I need you guys to help look at my code to see if I am doing something wrong. Here's my code
schedule.service.ts
searchSchedulesList(route: string, date)
let now = this.formatDate(this.today);
if (date != null)
return this.afs
.collection("schedules", ref =>
ref
.where("route", "==", route)
.where("date", "==", date)
.where("date", ">=", now)
.orderBy("date", "asc")
.orderBy("time", "asc")
)
.snapshotChanges();
else
return this.afs
.collection("schedules", ref => ref.where("route", "==", route))
.snapshotChanges();
schedule.component.ts
search(route: string, date)
this.scheduleService.searchSchedulesList(route, date).subscribe(data =>
this.schedules = data.map(e =>
return
id: e.payload.doc.id,
...e.payload.doc.data()
as Schedule;
);
);
This is the search form used to get the values from to and date
<form [formGroup]="searchForm">
<div class="row">
<div class="form-group col-3">
<select formControlName="from" id="from" class="form-control">
<option value="">From</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<select formControlName="to" id="to" class="form-control">
<option value="">To</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<input formControlName="date" type="date" class="form-control" />
</div>
<div class="col-3">
<button
class="btn btn-primary btn-sm"
(click)="
search(
searchForm.value.from + searchForm.value.to,
searchForm.value.date
)
"
>
Search
</button>
<button class="btn btn-secondary btn-sm" (click)="clear()">
Reset
</button>
</div>
</div>
</form>
javascript
add a comment |
I have implemented a search function in an angular 7 app that uses Firebase. I want the user to provide a from and to values always and a date value optionally. At the moment whenever a user provides all 3 values (from, to & date) the query returns the expected result. But if only from & to values are provided, the query returns expected result sometimes and doesn't at other times. I haven't been able to find a bug in my code so I need you guys to help look at my code to see if I am doing something wrong. Here's my code
schedule.service.ts
searchSchedulesList(route: string, date)
let now = this.formatDate(this.today);
if (date != null)
return this.afs
.collection("schedules", ref =>
ref
.where("route", "==", route)
.where("date", "==", date)
.where("date", ">=", now)
.orderBy("date", "asc")
.orderBy("time", "asc")
)
.snapshotChanges();
else
return this.afs
.collection("schedules", ref => ref.where("route", "==", route))
.snapshotChanges();
schedule.component.ts
search(route: string, date)
this.scheduleService.searchSchedulesList(route, date).subscribe(data =>
this.schedules = data.map(e =>
return
id: e.payload.doc.id,
...e.payload.doc.data()
as Schedule;
);
);
This is the search form used to get the values from to and date
<form [formGroup]="searchForm">
<div class="row">
<div class="form-group col-3">
<select formControlName="from" id="from" class="form-control">
<option value="">From</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<select formControlName="to" id="to" class="form-control">
<option value="">To</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<input formControlName="date" type="date" class="form-control" />
</div>
<div class="col-3">
<button
class="btn btn-primary btn-sm"
(click)="
search(
searchForm.value.from + searchForm.value.to,
searchForm.value.date
)
"
>
Search
</button>
<button class="btn btn-secondary btn-sm" (click)="clear()">
Reset
</button>
</div>
</div>
</form>
javascript
How do you query for thefromandto? Through therouteparameter I guess, but how are these related?
– Renaud Tarnec
Mar 8 at 11:20
@RenaudTarnec I used a form to getfromto&datevalues. The values forfrom&toare then concatenated and used asroutevalue. I have added the form code
– Mena
Mar 8 at 11:37
add a comment |
I have implemented a search function in an angular 7 app that uses Firebase. I want the user to provide a from and to values always and a date value optionally. At the moment whenever a user provides all 3 values (from, to & date) the query returns the expected result. But if only from & to values are provided, the query returns expected result sometimes and doesn't at other times. I haven't been able to find a bug in my code so I need you guys to help look at my code to see if I am doing something wrong. Here's my code
schedule.service.ts
searchSchedulesList(route: string, date)
let now = this.formatDate(this.today);
if (date != null)
return this.afs
.collection("schedules", ref =>
ref
.where("route", "==", route)
.where("date", "==", date)
.where("date", ">=", now)
.orderBy("date", "asc")
.orderBy("time", "asc")
)
.snapshotChanges();
else
return this.afs
.collection("schedules", ref => ref.where("route", "==", route))
.snapshotChanges();
schedule.component.ts
search(route: string, date)
this.scheduleService.searchSchedulesList(route, date).subscribe(data =>
this.schedules = data.map(e =>
return
id: e.payload.doc.id,
...e.payload.doc.data()
as Schedule;
);
);
This is the search form used to get the values from to and date
<form [formGroup]="searchForm">
<div class="row">
<div class="form-group col-3">
<select formControlName="from" id="from" class="form-control">
<option value="">From</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<select formControlName="to" id="to" class="form-control">
<option value="">To</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<input formControlName="date" type="date" class="form-control" />
</div>
<div class="col-3">
<button
class="btn btn-primary btn-sm"
(click)="
search(
searchForm.value.from + searchForm.value.to,
searchForm.value.date
)
"
>
Search
</button>
<button class="btn btn-secondary btn-sm" (click)="clear()">
Reset
</button>
</div>
</div>
</form>
javascript
I have implemented a search function in an angular 7 app that uses Firebase. I want the user to provide a from and to values always and a date value optionally. At the moment whenever a user provides all 3 values (from, to & date) the query returns the expected result. But if only from & to values are provided, the query returns expected result sometimes and doesn't at other times. I haven't been able to find a bug in my code so I need you guys to help look at my code to see if I am doing something wrong. Here's my code
schedule.service.ts
searchSchedulesList(route: string, date)
let now = this.formatDate(this.today);
if (date != null)
return this.afs
.collection("schedules", ref =>
ref
.where("route", "==", route)
.where("date", "==", date)
.where("date", ">=", now)
.orderBy("date", "asc")
.orderBy("time", "asc")
)
.snapshotChanges();
else
return this.afs
.collection("schedules", ref => ref.where("route", "==", route))
.snapshotChanges();
schedule.component.ts
search(route: string, date)
this.scheduleService.searchSchedulesList(route, date).subscribe(data =>
this.schedules = data.map(e =>
return
id: e.payload.doc.id,
...e.payload.doc.data()
as Schedule;
);
);
This is the search form used to get the values from to and date
<form [formGroup]="searchForm">
<div class="row">
<div class="form-group col-3">
<select formControlName="from" id="from" class="form-control">
<option value="">From</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<select formControlName="to" id="to" class="form-control">
<option value="">To</option>
<option
*ngFor="let destination of destinations"
value=" destination.abbreviation "
> destination.fullname </option
>
</select>
</div>
<div class="form-group col-3">
<input formControlName="date" type="date" class="form-control" />
</div>
<div class="col-3">
<button
class="btn btn-primary btn-sm"
(click)="
search(
searchForm.value.from + searchForm.value.to,
searchForm.value.date
)
"
>
Search
</button>
<button class="btn btn-secondary btn-sm" (click)="clear()">
Reset
</button>
</div>
</div>
</form>
javascript
javascript
edited Mar 8 at 15:34
Frank van Puffelen
243k29387414
243k29387414
asked Mar 8 at 11:12
MenaMena
435823
435823
How do you query for thefromandto? Through therouteparameter I guess, but how are these related?
– Renaud Tarnec
Mar 8 at 11:20
@RenaudTarnec I used a form to getfromto&datevalues. The values forfrom&toare then concatenated and used asroutevalue. I have added the form code
– Mena
Mar 8 at 11:37
add a comment |
How do you query for thefromandto? Through therouteparameter I guess, but how are these related?
– Renaud Tarnec
Mar 8 at 11:20
@RenaudTarnec I used a form to getfromto&datevalues. The values forfrom&toare then concatenated and used asroutevalue. I have added the form code
– Mena
Mar 8 at 11:37
How do you query for the
from and to? Through the route parameter I guess, but how are these related?– Renaud Tarnec
Mar 8 at 11:20
How do you query for the
from and to? Through the route parameter I guess, but how are these related?– Renaud Tarnec
Mar 8 at 11:20
@RenaudTarnec I used a form to get
from to & date values. The values for from & to are then concatenated and used as route value. I have added the form code– Mena
Mar 8 at 11:37
@RenaudTarnec I used a form to get
from to & date values. The values for from & to are then concatenated and used as route value. I have added the form code– Mena
Mar 8 at 11:37
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062011%2ffirebase-query-not-returning-results-everytime-it-runs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55062011%2ffirebase-query-not-returning-results-everytime-it-runs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How do you query for the
fromandto? Through therouteparameter I guess, but how are these related?– Renaud Tarnec
Mar 8 at 11:20
@RenaudTarnec I used a form to get
fromto&datevalues. The values forfrom&toare then concatenated and used asroutevalue. I have added the form code– Mena
Mar 8 at 11:37