Querying Firebase for objects will return a collection of data that

I need assistance with querying a Realtime Database structure for AEDs based on their owner. I want the query to return all AEDs (including children) that have a matching owner id.

Despite my efforts, I have been unable to achieve this even though it seems like it should be simple. Below is the code I am currently using:

var aedRef = dbRef.ref().child("aeds")
var query = aedRef.orderByChild("owner").equalTo(userID);
console.log(query);

Although I believe that this should work without issues, I keep getting the following output:

e {repo: e, path: e, Me: e, Le: true}

If anyone can provide some guidance or assistance, it would be greatly appreciated. Thank you!

Answer №1

query acts as a reference to a document and does not provide the query results directly. To retrieve data, you must utilize either .on or .once methods.

For detailed information on reading and writing data, refer to the Firebase documentation.

var aedRef = dbRef.ref().child("aeds");
var query = aedRef.orderByChild("owner").equalTo(userID);

// Retrieve data and listen for changes continuously
query.on('value', function(snapshot) {
  console.log(snapshot.val());
});

// Obtain data only once
query.once('value').then(function(snapshot) {
  console.log(snapshot.val());
});

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

Choosing a specific dropdown option by using xpath (or a more efficient method)

How can I specifically choose an element from the drop down menu? <li role="presentation" ng-repeat="match in $matches" ng-class="{active: $isActive($index)}" class="ng-scope active"> <a style="cursor: default" role="menuitem" tabindex="-1" n ...

In ReactJS, the error message 'callback is not a function' is indicating a TypeError

I am unsure of the reason behind this response's body. "<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <script src="/charting_library/charting_library.m ...

Using the datepicker class in an input field causes issues with the functionality of the bootstrap datepicker, specifically the autoclose, endDate, and startDate properties do not function as

I'm facing an issue with my code when I add the datepicker to the input field's class. JS $(document).ready(function () { $("#ActionDateInput").datepicker({ autoclose: true, endDate: new Date() }); }); HTML <input type= ...

The attempt to send a complex javascript object through AJAX to the server is unsuccessful

Looking at my JavaScript object structure, it appears as follows: var obj = { "name": "username", "userid": "9999", "object1": { "subObject1": { "subArray1": [], "subArray2": [] }, "subObject2" ...

Expanding JSON array parameter with jQuery

Currently, I am diving into the world of jQuery extend method and trying to grasp its concepts. According to the official documentation, the merge operation carried out by $.extend() is not recursive by default. This means that if a property of the first o ...

Guide for adding a basic JS widget or gadget block to a Nuxtjs website

When integrating code from services like Google Analytics or Statcounter into Nuxtjs based webapps/sites, what is the most effective method to include these script blocks? Here is an example of code from Statcounter for adding to Nuxtjs: <!-- Default ...

Using jQuery to retrieve the weight and grade inputs, then performing a calculation based on a specific formula

Looking for help with calculating weighted grades based on input? Weighted grade = = w1×g1+ w2×g2+ w3×g3 = 30%×80+ 50%×90+ 20%×72 = 83.4 Below is the current implementation: function total(){ var grade = 0; var weight = 0; $(& ...

Executing a BigQuery query through the command line interface, with a JSON table schema specified

I am attempting to load data from a comma-separated test file named 'Davetest.csv' and utilize a JSON schema stored in a file called 'testjson.json' Unfortunately, I am facing difficulties in getting it to properly recognize the table ...

Is there a way to selectively load only the <head> content from AJAX data and update the current <head> element?

While attempting to retrieve the <head> content of data using AJAX and replace it with the current one, I am encountering errors and the code at the bottom is not functioning as expected. $('head').html($(data).find('head:first') ...

Having trouble creating an axios instance in Vue

I recently came across a helpful tip in an article about using axios for AJAX requests in Vue. The author mentioned that by setting Vue.prototype.$http = axios, we can then use this.$http within the Vue instance, which worked perfectly for me. However, wh ...

Angular 6: Simplify Your Navigation with Step Navigation

Can someone please assist me with configuring a navigation step? I tried using viewchild without success and also attempted to create a function with an index++ for three components on the same page. However, I am unable to achieve the desired outcome. Any ...

Uninstalling NPM License Checker version

Utilizing the npm license checker tool found at https://www.npmjs.com/package/license-checker The configuration in license-format.json for the customPath is as follows: { "name": "", "version": false, "description&quo ...

Transferring an array from PHP to JavaScript within a function

Having trouble accessing the array returned by a PHP function in JavaScript. Instead of seeing the actual array, I get the message: function Array() { [native code] } How can I retrieve and work with the items in the array? When I try using alert(pad ...

Incorporate a JavaScript form into a controller in MVC4

I'm facing an issue where I need to trigger a JavaScript function from within a controller method in my project. Here is the code snippet that I am using: Public Function redirectTo() As JavaScriptResult Return JavaScript("ToSignUp()") E ...

Guide on extracting JSON data in C# without using any third-party libraries or dependencies

Currently, I am in the process of developing a string extension namespace for c# and a key requirement is for it to have the capability to parse to/from JSON. I am not considering the option of using 'json.net' as I prefer not to include any thir ...

Ensure that a group of checkboxes is mandatory

I currently have a series of checkboxes set up like so: <label>What is your preferred movie genre?</label> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="genre1" name="genre" ...

Selecting keys using wildcards with MySQL JSON_EXTRACT

Here is the json data currently stored in my database: { RootData: { 202003: { 201903: { "abc": 123, xyz: 456 }, data1: { }, data2: { } } } } I am attempting to ex ...

Significant delay in processing second jQuery Ajax call

Attempting a simple Ajax call with page content refresh using the following code snippet: $("a.ajaxify-watched").bind("click", function(event) { $item = $(this); $.ajax({ url: $(this).attr("href"), global: false, type: "G ...

Stop the http requests in Angular as the user continually types in the autocomplete input field

Currently, I have an input field that utilizes a material autocomplete component. This component makes calls to the server for results as the user types. While it is working correctly for now with the server returning results in order, I am looking for a ...

Working with nested lists in C# JSON to return data in a hierarchical structure

public class Entry { public string playerOrTeamId { get; set; } public string playerOrTeamName { get; set; } public string division { get; set; } public int leaguePoints { get; set; } public int wins { get; set; } public int losses ...