magnetar icon indicating copy to clipboard operation
magnetar copied to clipboard

add `startAfter` usage example

Open mesqueeb opened this issue 2 years ago • 0 comments

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 avatar Jun 04 '22 08:06 mesqueeb