Skip to content

Firestore: Use simple types for cursors #4109

Closed

Description

@dhermes

i.e.

db = firestore.Client()
query = db.collection('cities').order_by('population').start_at(1000000)

rather than the current

db = firestore.Client()
query = db.collection('cities').order_by('population').start_at({'population': 1000000})

/cc @samtstern @jonparrott

Activity

  1. self-assigned this
    on Oct 3, 2017
  2. dhermes commented on Oct 3, 2017

    @dhermes
    ContributorAuthor

    If I was to implement this I could, by accepting *values and then making sure either

    1. len(values) == len(self._orders)
    2. len(values) <= len(self._orders)

    then we could just match each value with the corresponding order. It's documented that subsequent calls to start_at() just RESET the start point wholesale (and start_after() also wipes it, and similar for end_before() / end_at()).

    Also the question would be if we should still accept a dictionary or DocumentSnapshot (which IMO is a "saner" interface). @jonparrott indicates yes.


    From @samtstern:

    Cursors can be on multiple fields but you have to specify each one. Here are some Android snippets to demonstrate:

    // Will return all Springfields
    db.collection("cities")
            .orderBy("name")
            .orderBy("state")
            .startAt("Springfield");
    
    // Will return "Springfield, Missouri" and "Springfield, Wisconsin"
    db.collection("cities")
            .orderBy("name")
            .orderBy("state")
            .startAt("Springfield", "Missouri");
  3. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Nov 2, 2017
  4. schmidt-sebastian commented on Jan 29, 2018

    @schmidt-sebastian

    Firestore should also accept DocumentSnapshot cursors similar to googleapis/google-cloud-java#2768

  5. chemelnucfin commented on Feb 26, 2018

    @chemelnucfin
    Contributor

    I'm going to put this in the back log for now and track it through here:
    Feature Requests

  6. schmidt-sebastian commented on May 4, 2018

    @schmidt-sebastian

    @chemelnucfin I don't see an issue for DocumentSnapshot cursors. The issue that I see in Feature Request (#4109) cleans up the cursor API, which is a precursor for googleapis/google-cloud-java#2768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the Firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo