Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add startAfter usage example #91

Open
mesqueeb opened this issue Jun 4, 2022 · 0 comments
Open

add startAfter usage example #91

mesqueeb opened this issue Jun 4, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@mesqueeb
Copy link
Member

mesqueeb commented Jun 4, 2022

required setup:

const profileCollection = magnetar.collection('profiles').where('show', '==', true).where('archived', '==', false)

const query = profileCollection
  .orderBy('lastActiveOrSomething')
  .limit(50)

const lastProfile  = computed(() => {
  return [...profileCollection.orderBy('lastActiveOrSomething').data.values()].pop()
})

then either:

const profiles = ref([])

const fetchMore = async () => {
  const newProfiles = await query.startAfter(lastProfile.value).fetch()
  // push to profiles
  profiles.value.push(...newProfiles)
}

or

const fetchMore = async () => {
  await query.startAfter(lastProfile.value).fetch()
}

and

<template>
  {{ [...profiles.data.values()] }}
</template>
@mesqueeb mesqueeb added the documentation Improvements or additions to documentation label Jun 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants