Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
How can we combine startAfter() method in firebase based on condition?

I am writing a query to paginate my data in firebase. But i have a simple and quick question. is it possible to add startAfter() method based on conditions like below? If possible then please guide me because I tried different ways but it is not working.

onMounted(() => {
  loadPapers()
})

const loadPapers = () => {
const savedTopifyPapers = db.collection('savedTopifyPapers')
  savedTopifyPapers.orderBy('timeStamp', 'asc').limit(1)
  if (lastDoc.value) {
    savedTopifyPapers.startAfter(lastDoc.value)
  }
  savedTopifyPapers.onSnapshot((snapshot) => {
    lastDoc.value = snapshot.docs[snapshot.docs.length - 1]
    if (snapshot.empty) {
      loadingData.value = false
    }
    papersData.value = snapshot.docs.map((doc) => {
      const data = doc.data()
      const id = doc.id
      loadingData.value = false
      return { id, ...data }
    })
    papersDataLength.value = papersData.value.length
  })

Any solution appreciated!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!