Skip to content

feat(store): store snapshot objects in state for use in pagination #203

Open
@jaschaio

Description

It would be great if I could access the original firestore client API objects through this library as well.

This begins at accessing the original firestore object I am passing over to the redux-firestore store enhancer and ends at the individual document snapshots I get back from api calls.

A simple example is that I would like to query the next set of documents within a collection startingFrom a document snapshot like described in the Firestore Documentation. This already works with redux-firestore, but I have to get the original document snapshot again myself as its not available through the store:

// Pseudo code

// Get Redux-Firestore Object from Store
const { firestore } = this.store;

// Get current State from Store
const { firestore: { ordered: { 'cars.1': items } } } = this.store.getState();

// Get Snapshot of the last queried document
var snapshot = await firestore.collection( 'cars' ).doc( items[ items.length - 1 ].id ).get();

// Do the firestore query with startFrom = snapshot to get the next page of results
firestore.get( {
    collection: 'cars',
    limit: 10,
    startAfter: snapshot
} );

This is suboptimal as redux-firestore should already have this snapshot, but it throws it away and only stores the data of each document snapshot.

Activity

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

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions