Is there a way to modify a Firestore query?
When I use the code below the query will ignore the startAfter
let query = firestore.collection('results')
.where('groupId', '==', req.query.groupId)
.where('seasonInfo.roundId', '==', req.query.roundId)
.orderBy('results.totalPoints', 'desc')
.orderBy('lastPick', 'asc')
if (req.query.lastPoints && req.query.lastDate) {
query.startAfter(parseInt(req.query.lastPoints), req.query.lastDate)
}
const pickDocs = await query.limit(10).get()
So I have to write the whole thing in order to make it work.
let query = firestore.collection('results')
.where('groupId', '==', req.query.groupId)
.where('seasonInfo.roundId', '==', req.query.roundId)
.orderBy('results.totalPoints', 'desc')
.orderBy('lastPick', 'asc')
if (req.query.lastPoints && req.query.lastDate) {
query = firestore.collection('results')
.where('groupId', '==', req.query.groupId)
.where('seasonInfo.roundId', '==', req.query.roundId)
.orderBy('results.totalPoints', 'desc')
.orderBy('lastPick', 'asc')
.startAfter(parseInt(req.query.lastPoints), req.query.lastDate)
}
const pickDocs = await query.limit(10).get()
Is it possible to modify a query without re-entering all data?