Query for Firebase data with nested timestamp range conditions

I am encountering some challenges with nested queries:

firebase.database().ref().child('panels').child('qa')
      .orderByChild('completed')
      .startAt(firstDay.getTime()) // January 1st, 2016
      .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
      .once('value', function(snapshot) {
        $log.log(snapshot.numChildren());
      });

It returns 0

However, when I move 'completed' to the first level of the node, it works as expected:

firebase.database().ref().child('panels')
      .orderByChild('completed')
      .startAt(firstDay.getTime()) // January 1st, 2016
      .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
      .once('value', function(snapshot) {
        $log.log(snapshot.numChildren());
      });

This time it returns 10;

Can anyone shed light on why the nested approach is not functioning correctly?

Answer №1

So here's what the issue was:

   firebase.database().ref().child('panels')
    .orderByChild('qa/completed')
    .startAt(firstDay.getTime()) // January 1st, 2016
    .endAt(lastDay.getTime()) // current date (aug, 25th 2016)
    .once('value', function(snapshot) {
      $log.log(snapshot.numChildren());
    });

Remember to orderByChild the nested data for it to work properly

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issues with SwiftUI reactivity when using asynchronous Firebase requests causing variables not to update

Trying to integrate a friendship model using firebase and SwiftUI. In one of the views, I have a method that checks friendship status when it appears: Update: Made isFriend a published variable for updating class UserViewModel : ObservableObject{ ...

The checkbox fails to display as selected in the user interface despite setting the checked property to true in JavaScript

In the table generated dynamically using an ng-repeat, I have checkboxes. The checkboxes are created as shown below: <input type="checkbox" id="chkView{{::myObj.TeamId}}" ng-disabled="disableView(myObj)" ng-click="setViewSelectio ...

The search for 'sth' cannot be done using the 'in' operator on an undefined value

Here is the code snippet I'm working on: . . keydown: function(ev) { clearTimeout( $(this).data('timer') ); if ( 'abort' in $(this).data('xhr') ) $(this).data('xhr').abort(); // encountering an ...

Add a fresh column in the table that includes modified values from an existing column, affected by a multiplication factor provided through a text input

I'm currently working on a Laravel website where I have a pricing table sourced from a database. The Retail Price column in this table serves as the base for calculating and populating a Discount Price column using a multiplier specified in a text inp ...

What is the process for transferring data from a Firestore collection to the Vuex State in

My objective is to integrate a firestore collection with the Vuex state in order to utilize it across multiple pages. I attempted to follow this guide: How to get collection from firestore and set to vuex state when the app is rendered? After following ...

Having trouble adjusting the grid's width property

My personal page features a section dedicated to displaying my skills and proficiency in various programming languages (although it may not be entirely accurate). I am struggling to adjust the width of the Skill grid to match the layout of the other grids ...

employing ajax for handling a form

Currently, I am facing an issue with updating a user's email on a page. The div refreshes upon submission as intended, but the database is not being updated, and I can't figure out why. My layout consists of a single page where clicking a menu l ...

What is the recommended sequence for using decorators in NestJS: @Body(), @Params(), @Req(), @Res()?

How can I properly access the res object to send httpOnly cookies and validate the body with DTO? I keep running into issues every time I attempt it. What is the correct order for these parameters? ...

Displaying an alert on a webpage that shows a label input using JavaScript and

I'm currently working with HTML5 and JavaScript and I'm facing a challenge. I want to create a feature where users can input any word into a label, and when they click on a button, an alert is triggered with the given text. However, despite my ...

Having trouble importing a component conditionally within a nested component

I am attempting to dynamically import and render one of two components based on the value returned by a prop (lang). If props.lang is set to spanish, then it should import and render a component named <Spain />; otherwise, <UnitedStates />: /* ...

What is the appropriate way to incorporate a dash into an object key when working with JavaScript?

Every time I attempt to utilize a code snippet like the one below: jQuery.post("http://mywebsite.com/", { array-key: "hello" }); An error message pops up saying: Uncaught SyntaxError: Unexpected token - I have experimented with adding quotation m ...

The orbit controls are malfunctioning, preventing the mouse from adjusting the view

I've been struggling to solve this issue for some time now and I'm not sure if it's related to the OrbitControls.js file or my own code. My goal is simple - I just want the orbit controls to work, but unfortunately nothing is moving as expec ...

Removing an item from a dictionary within a Firestore document in Swift

Currently, my UITableView contains edit and delete buttons. I am currently exploring how to delete an element within a map/dictionary from the database. For example, I want to remove: dailyIntake { 1568695516 { amount : 12 timestamp : 1568695516.837234 ...

Tips for achieving an eye-catching text and image layout on a single page of your Wordpress blog

I've been exploring ways to achieve a design concept for my blog layout. I envision having the text and thumbnail displayed side by side, each taking up 50% of the width until the image reaches its end. Once the image ends, I want the text to span the ...

Exploring JavaScript Query: Combining AND and OR with Radios, Checkboxes, and Text Fields for Dynamic Form Functionality

I have a code snippet in JSFiddle that I need help with. The issue is that I want to use both a radio check AND a text entry in a field to enable other radios, checkboxes, and text fields. Currently, the code only enables items based on radio option 1 OR r ...

Kids in the realm of useCallback are stuck in dependency pur

My understanding of useCallback was to prevent rerendering, so I've implemented it in all my functions. However, I have a feeling that this might not be the best approach. What's even worse is that by using it everywhere, I am passing dependenci ...

Struggling to meet PWA lighthouse test requirements even with service worker correctly installed

Recently, I've been diving into PWA development and I've encountered a roadblock. Despite successfully setting up my service worker and caching files, my app is not receiving the PWA mark for being installable when tested with Lighthouse. I' ...

Proper method for refreshing React context

Currently, I am implementing Gatsby along with a layout plugin to maintain the persistence of my navbar while the content on the page below it changes. My main objective is to have animations run smoothly during page transitions without the navbar reloadin ...

The HTML table seems to be inexplicably replicating defaultValue values

I'm encountering an issue where, when I use JavaScript to add a new table data cell (td), it ends up copying the defaultValue and innerText of the previous td in the new cell. This is confusing to me because I am simply adding a new HTML element that ...

Adjust the DOM based on the output of the function

I'm currently working on creating a list where only one element can be active at a time. The state is updating correctly, but I'm facing an issue with the isActive function. It only activates initially and doesn't trigger when the state chan ...