Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

DocumentSnapshot in startAt or startAfter cause an error: Error: Cannot encode type ([object Object]) to a Firestore Value #98

@ErbolLab

Description

@ErbolLab

Hello,

According to the https://firebase.google.com/docs/firestore/query-data/query-cursors
we could be able to use a document snapshot to define the query cursor.

but in the fact, it throws an error: "Error: Cannot encode type ([object Object]) to a Firestore Value".

Environment details

  • OS: Windows 10
  • Node.js version: 9.2.0
  • npm version: 5.5.1
  • @google-cloud/firestore version: 0.10.0

Steps to reproduce

const first = firestore.collection("collectionName")
  .orderBy("population")
  .limit(25)
  .get()
  .then(function (documentSnapshots) {
    // Get the last visible document
    const lastVisible = documentSnapshots.docs[documentSnapshots.docs.length-1];

    const next = firestore.collection("collectionName")
      .orderBy("population")
      .startAfter(lastVisible)
      .limit(25)
      .get()
      .then(data => {
        console.log(data.docs.length);
      });
  });

I tried the same with @firebase/firestore and it works just fine.

Metadata

Metadata

Labels

🚨This issue needs some love.api: firestoreIssues related to the googleapis/nodejs-firestore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions