magnetar
magnetar copied to clipboard
add `startAfter` usage example
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>