How to get multiple records from firebase?How do you write multiline strings in Go?How to store and view images on firebase?Get users by name property using Firebasefirebase/angularFire querying with startAt/endAt doesn't workQuery based on multiple where clauses in FirebaseElasticsearch is not using template and mapping while indexing data from FirebaseFirebase for complex query. A no go?Android FIrebase Query populate FirebaseListAdapter 2 nodes belowComplex firebase read query - String, Float, Int and NSArrayDelete record in firebase with Javascript - Vuejs

Do dead weight 'components' exist?

Locked out of my own server: getting "Too many authentication failures" right away when connecting via ssh

Does cashing a 3% share harm the company itself?

What is the equivalent of "if you say so" in German?

Should `sudo less ...` change the ownership of `~/.lesshst`?

How to Keep Winged People Where They Belong?

Commercial satellite retrieval - possible?

A lightweight version of std::shared_ptr<T>

When is the best time to visit the Australian outback?

What is Trump's position on the whistle blower allegations? What does he mean by "witch hunt"?

How to play this rhythm in Beethoven's Moonlight Sonata? as a 4/3 polyrythm or as 6/16?

How can you castle legally in Chess960 when the castling rook is on the king's destination square?

Modification of a public property - LWC

Can I say: “The train departs at 16 past every hour“?

What does "T.O." mean?

What manages Upper Memory Blocks (UMBs) in MS-DOS?

How likely are you to be injured by falling shot from a game shoot?

Wood versus marble rolling pin 'performance'

Washing the skin of a dead rat

Players who play fast in longer time control games

Why do we worry about overfitting even if "all models are wrong"

How does an all-female medieval country maintain itself?

What happens if a country signs mutual defense treaties with several countries who later go to war with each other?

Energies of Virtual Molecular Orbitals (LUMO)



How to get multiple records from firebase?


How do you write multiline strings in Go?How to store and view images on firebase?Get users by name property using Firebasefirebase/angularFire querying with startAt/endAt doesn't workQuery based on multiple where clauses in FirebaseElasticsearch is not using template and mapping while indexing data from FirebaseFirebase for complex query. A no go?Android FIrebase Query populate FirebaseListAdapter 2 nodes belowComplex firebase read query - String, Float, Int and NSArrayDelete record in firebase with Javascript - Vuejs






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0

















I have a firebase db with data like below:
enter image description here



I want to pull multiple records based on certain criteria. I've figured out how to pull a single record based on an ID using the method below:



ref := fbDB.NewRef("/Event/123")
event := data.EventData
if err := ref.Get(c, &event); err != nil
// error handling stuff



This loads event with the data I would expect. When I try to modify this code to select multiple records with the code below:



type EventResults struct 
Events []data.EventData

...
ref := fbDB.NewRef("/Event")
res := EventResults
if err := ref.Child("candy").OrderByValue().StartAt(350).Get(c, &res); err != nil
//error handling stuff



res.Events is always an empty array (and err is nil).



Can anyone see what I'm doing wrong?










share|improve this question
































    0

















    I have a firebase db with data like below:
    enter image description here



    I want to pull multiple records based on certain criteria. I've figured out how to pull a single record based on an ID using the method below:



    ref := fbDB.NewRef("/Event/123")
    event := data.EventData
    if err := ref.Get(c, &event); err != nil
    // error handling stuff



    This loads event with the data I would expect. When I try to modify this code to select multiple records with the code below:



    type EventResults struct 
    Events []data.EventData

    ...
    ref := fbDB.NewRef("/Event")
    res := EventResults
    if err := ref.Child("candy").OrderByValue().StartAt(350).Get(c, &res); err != nil
    //error handling stuff



    res.Events is always an empty array (and err is nil).



    Can anyone see what I'm doing wrong?










    share|improve this question




























      0












      0








      0


      1






      I have a firebase db with data like below:
      enter image description here



      I want to pull multiple records based on certain criteria. I've figured out how to pull a single record based on an ID using the method below:



      ref := fbDB.NewRef("/Event/123")
      event := data.EventData
      if err := ref.Get(c, &event); err != nil
      // error handling stuff



      This loads event with the data I would expect. When I try to modify this code to select multiple records with the code below:



      type EventResults struct 
      Events []data.EventData

      ...
      ref := fbDB.NewRef("/Event")
      res := EventResults
      if err := ref.Child("candy").OrderByValue().StartAt(350).Get(c, &res); err != nil
      //error handling stuff



      res.Events is always an empty array (and err is nil).



      Can anyone see what I'm doing wrong?










      share|improve this question















      I have a firebase db with data like below:
      enter image description here



      I want to pull multiple records based on certain criteria. I've figured out how to pull a single record based on an ID using the method below:



      ref := fbDB.NewRef("/Event/123")
      event := data.EventData
      if err := ref.Get(c, &event); err != nil
      // error handling stuff



      This loads event with the data I would expect. When I try to modify this code to select multiple records with the code below:



      type EventResults struct 
      Events []data.EventData

      ...
      ref := fbDB.NewRef("/Event")
      res := EventResults
      if err := ref.Child("candy").OrderByValue().StartAt(350).Get(c, &res); err != nil
      //error handling stuff



      res.Events is always an empty array (and err is nil).



      Can anyone see what I'm doing wrong?







      firebase go firebase-realtime-database






      share|improve this question














      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 20:41









      Abe MiesslerAbe Miessler

      55.6k76 gold badges255 silver badges416 bronze badges




      55.6k76 gold badges255 silver badges416 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1


















          It's empty because when retrieving data you need to traverse the database and pass through each node.



          In your case you have this:



          ref.Child("candy");


          Here ref is referencing the node Event and under Event you have different Ids (123, 789), therefore you need to access these nodes before trying to access node candy.




          If you want to retrieve a list of candy that are under Event, then you should iterate inside the direct child of node Event then you will be able to access node candy.



          Example:



          f := firego.New("https://my-firebase-app.firebaseIO.com", nil)
          var res map[string]interface

          ref := fbDB.Ref("/Event")
          if err := ref.OrderBy("candy").StartAt(3).Value(&res); err != nil




          You need to use the OrderBy query to be able to retrieve result based on the value of of candy. For example, in my code OrderBy("candy").StartAt(3), this query will give you a result where the value of candy starts with 3. candy :300



          Check the docs:



          https://godoc.org/gopkg.in/zabawaba99/firego.v1






          share|improve this answer




























          • So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

            – Abe Miessler
            Mar 28 at 22:40












          • check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

            – Peter Haddad
            Mar 28 at 23:07












          • Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

            – Abe Miessler
            Mar 29 at 1:34











          • @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

            – Peter Haddad
            Mar 29 at 5:01



















          0


















          This is basically what Peter posted above but the exact code I ended up using is below:



          ref := fbDB.NewRef("/Event")
          var res map[string]data.EventData

          if err := ref.OrderByChild("candy").StartAt(350).Get(c, &res); err != nil
          //Error handling stuff






          share|improve this answer



























            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/4.0/"u003ecc by-sa 4.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
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406519%2fhow-to-get-multiple-records-from-firebase%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown


























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1


















            It's empty because when retrieving data you need to traverse the database and pass through each node.



            In your case you have this:



            ref.Child("candy");


            Here ref is referencing the node Event and under Event you have different Ids (123, 789), therefore you need to access these nodes before trying to access node candy.




            If you want to retrieve a list of candy that are under Event, then you should iterate inside the direct child of node Event then you will be able to access node candy.



            Example:



            f := firego.New("https://my-firebase-app.firebaseIO.com", nil)
            var res map[string]interface

            ref := fbDB.Ref("/Event")
            if err := ref.OrderBy("candy").StartAt(3).Value(&res); err != nil




            You need to use the OrderBy query to be able to retrieve result based on the value of of candy. For example, in my code OrderBy("candy").StartAt(3), this query will give you a result where the value of candy starts with 3. candy :300



            Check the docs:



            https://godoc.org/gopkg.in/zabawaba99/firego.v1






            share|improve this answer




























            • So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

              – Abe Miessler
              Mar 28 at 22:40












            • check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

              – Peter Haddad
              Mar 28 at 23:07












            • Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

              – Abe Miessler
              Mar 29 at 1:34











            • @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

              – Peter Haddad
              Mar 29 at 5:01
















            1


















            It's empty because when retrieving data you need to traverse the database and pass through each node.



            In your case you have this:



            ref.Child("candy");


            Here ref is referencing the node Event and under Event you have different Ids (123, 789), therefore you need to access these nodes before trying to access node candy.




            If you want to retrieve a list of candy that are under Event, then you should iterate inside the direct child of node Event then you will be able to access node candy.



            Example:



            f := firego.New("https://my-firebase-app.firebaseIO.com", nil)
            var res map[string]interface

            ref := fbDB.Ref("/Event")
            if err := ref.OrderBy("candy").StartAt(3).Value(&res); err != nil




            You need to use the OrderBy query to be able to retrieve result based on the value of of candy. For example, in my code OrderBy("candy").StartAt(3), this query will give you a result where the value of candy starts with 3. candy :300



            Check the docs:



            https://godoc.org/gopkg.in/zabawaba99/firego.v1






            share|improve this answer




























            • So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

              – Abe Miessler
              Mar 28 at 22:40












            • check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

              – Peter Haddad
              Mar 28 at 23:07












            • Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

              – Abe Miessler
              Mar 29 at 1:34











            • @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

              – Peter Haddad
              Mar 29 at 5:01














            1














            1










            1









            It's empty because when retrieving data you need to traverse the database and pass through each node.



            In your case you have this:



            ref.Child("candy");


            Here ref is referencing the node Event and under Event you have different Ids (123, 789), therefore you need to access these nodes before trying to access node candy.




            If you want to retrieve a list of candy that are under Event, then you should iterate inside the direct child of node Event then you will be able to access node candy.



            Example:



            f := firego.New("https://my-firebase-app.firebaseIO.com", nil)
            var res map[string]interface

            ref := fbDB.Ref("/Event")
            if err := ref.OrderBy("candy").StartAt(3).Value(&res); err != nil




            You need to use the OrderBy query to be able to retrieve result based on the value of of candy. For example, in my code OrderBy("candy").StartAt(3), this query will give you a result where the value of candy starts with 3. candy :300



            Check the docs:



            https://godoc.org/gopkg.in/zabawaba99/firego.v1






            share|improve this answer
















            It's empty because when retrieving data you need to traverse the database and pass through each node.



            In your case you have this:



            ref.Child("candy");


            Here ref is referencing the node Event and under Event you have different Ids (123, 789), therefore you need to access these nodes before trying to access node candy.




            If you want to retrieve a list of candy that are under Event, then you should iterate inside the direct child of node Event then you will be able to access node candy.



            Example:



            f := firego.New("https://my-firebase-app.firebaseIO.com", nil)
            var res map[string]interface

            ref := fbDB.Ref("/Event")
            if err := ref.OrderBy("candy").StartAt(3).Value(&res); err != nil




            You need to use the OrderBy query to be able to retrieve result based on the value of of candy. For example, in my code OrderBy("candy").StartAt(3), this query will give you a result where the value of candy starts with 3. candy :300



            Check the docs:



            https://godoc.org/gopkg.in/zabawaba99/firego.v1







            share|improve this answer















            share|improve this answer




            share|improve this answer








            edited Mar 28 at 23:07

























            answered Mar 28 at 21:29









            Peter HaddadPeter Haddad

            28.6k12 gold badges53 silver badges70 bronze badges




            28.6k12 gold badges53 silver badges70 bronze badges















            • So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

              – Abe Miessler
              Mar 28 at 22:40












            • check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

              – Peter Haddad
              Mar 28 at 23:07












            • Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

              – Abe Miessler
              Mar 29 at 1:34











            • @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

              – Peter Haddad
              Mar 29 at 5:01


















            • So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

              – Abe Miessler
              Mar 28 at 22:40












            • check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

              – Peter Haddad
              Mar 28 at 23:07












            • Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

              – Abe Miessler
              Mar 29 at 1:34











            • @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

              – Peter Haddad
              Mar 29 at 5:01

















            So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

            – Abe Miessler
            Mar 28 at 22:40






            So what I actually want is to get the individual events where the value for candy falls within a certain range. How do I limit the event records that i'm pulling based on the value of candy? I understand that ref.Child("candy") isn't right but i'm not clear on what I should be doing instead

            – Abe Miessler
            Mar 28 at 22:40














            check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

            – Peter Haddad
            Mar 28 at 23:07






            check my edit in the answer , also I dont know golang, but the code that I wrote should work according to the search that I did about go

            – Peter Haddad
            Mar 28 at 23:07














            Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

            – Abe Miessler
            Mar 29 at 1:34





            Hrrm, I'm not using the firego package but let me see if I can work out how to apply it to the built in library: godoc.org/firebase.google.com/go/db

            – Abe Miessler
            Mar 29 at 1:34













            @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

            – Peter Haddad
            Mar 29 at 5:01






            @AbeMiessler okay if you are using the link above then do ref.OrderByChild("candy").StartAt(3).Get(&res)

            – Peter Haddad
            Mar 29 at 5:01














            0


















            This is basically what Peter posted above but the exact code I ended up using is below:



            ref := fbDB.NewRef("/Event")
            var res map[string]data.EventData

            if err := ref.OrderByChild("candy").StartAt(350).Get(c, &res); err != nil
            //Error handling stuff






            share|improve this answer






























              0


















              This is basically what Peter posted above but the exact code I ended up using is below:



              ref := fbDB.NewRef("/Event")
              var res map[string]data.EventData

              if err := ref.OrderByChild("candy").StartAt(350).Get(c, &res); err != nil
              //Error handling stuff






              share|improve this answer




























                0














                0










                0









                This is basically what Peter posted above but the exact code I ended up using is below:



                ref := fbDB.NewRef("/Event")
                var res map[string]data.EventData

                if err := ref.OrderByChild("candy").StartAt(350).Get(c, &res); err != nil
                //Error handling stuff






                share|improve this answer














                This is basically what Peter posted above but the exact code I ended up using is below:



                ref := fbDB.NewRef("/Event")
                var res map[string]data.EventData

                if err := ref.OrderByChild("candy").StartAt(350).Get(c, &res); err != nil
                //Error handling stuff







                share|improve this answer













                share|improve this answer




                share|improve this answer










                answered Mar 29 at 6:08









                Abe MiesslerAbe Miessler

                55.6k76 gold badges255 silver badges416 bronze badges




                55.6k76 gold badges255 silver badges416 bronze badges































                    draft saved

                    draft discarded















































                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406519%2fhow-to-get-multiple-records-from-firebase%23new-answer', 'question_page');

                    );

                    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









                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript