Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › Firebase startAt causing undefined return

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24393

    Edward

    Hey!

    So i’m working on a ‘typeahead’ function whilst will check my Database to search users as they type. However when I try to implement  the ‘startAt’ query property I only return undefined.

     

    I have tried testing with hardcoding my ‘startAt:’ key however this still returns the same?

     

    my function is as such

     

        function searchUsers(searchString) {
            db.getValue("public/nameList/", {
                            orderByChild: true,
                            startAt: searchString,      //if i comment this i return the branch in full.
                            limitToFirst: 10,
                        }, function(success, key, value) {
                            if(success) {
                                searchArr = []
                                searchArr = value
                                console.debug("Read user value for key", key, "from DB:", value)
                            }
                        })
        }

     

     

    A sample of my JSON is

     

    nameList: {
      "EddieLaw245" : 530343772383,
      "EddieLawrence91" : 530343772385,
      "EdwardL91" : 530343772386,
      "EdwardLaw" : 530343772384,
      "Edwardlawrence91" : 530343772380,
      "JoBrownLondon" : 530343772381,
      "KatiePrescottHair" : 543592635596,
      "Tracey-Sweeting" : 530343772382
    }
    

     

     

    What i want, with the above example – is as i type Ed it will immediately filter out the bottom 3 entries, if i then type EDW it will filter out the EDD entries and so on.

     

    Thanks

    #24395

    Edward
    #24410

    David

    Hallo Edward,

    dataBase.getValue("public/nameList/", {
                                          "orderByKey": true,
                                          "startAt": "Edd",
                                          "endAt": "Edd~",
                                          "limitToFirst": 10,
                                      }, function(success, key, value) {
                                          if(success) {
                                              for (var name in value) {
                                                  console.log(name, value[name])
                                              }
                                          }
                                      })

    should do it.

    In the Felgo-Doc you should use “orderByKeys”. But “orderByKey” works…

    #24411

    Edward

    Amazing! even with the variable as ‘startAt’ & ‘endAt’ works perfectly!

     

    Unsure if it’s placing the startAt/endAt/orderBy ect in quotation marks or simply the orderbyKey (not Keys)

     

    works perfectly!

     

    Thanks

    #24414

    David

    You can do it without quotation marks. orderByKey, startAt and endAt is important.

Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded