Giter VIP home page Giter VIP logo

Comments (5)

davydany avatar davydany commented on May 29, 2024 1

From what I can see, you can't limit or sort a within query. I am looking for a solution for this when I stumbled onto your issue. I'd be curious to know if that is possible from the creator.

from geoflutterfire.

DarshanGowda0 avatar DarshanGowda0 commented on May 29, 2024 1

Sorry for the delayed response!

  • No, sorts are not supported because of the need to perform orderBy() on geohashes before filtering them out. So, appending orderBy() with another field would mess with the startAt() and orderBy() combination used in the library. You can read about this here - https://firebase.google.com/docs/firestore/query-data/order-limit-data
  • limit() is a special case, a hard limit on 50 documents is not possible. But, the next best alternative is limiting by 5. The library basically runs 9 queries in a sequence, i.e 1 geohash in the center and 8 surrounding geohashes, all within the specified radius with some edge cases(mostly because of the square shape). So, you can engineer to limit each query to a hard limit of 5, so the number of reads inside each sub-hash is limited to 9*5 reads overall. This is just an alternative solution to control the number of reads that could happen, but not a complete limit() alternative.

from geoflutterfire.

awhitford avatar awhitford commented on May 29, 2024 1

BTW... It appears that within returns records sorted by the distance from the center. I did not see that documented.

from geoflutterfire.

travisjayday avatar travisjayday commented on May 29, 2024

@awhitford Thank you for your comment, which saved me the time from testing the ordering of .within() myself. Agreed, it should be documented somewhere.

from geoflutterfire.

justChris avatar justChris commented on May 29, 2024

Do you think a proper limit functionality will presumably be available? Thanks.

from geoflutterfire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.