AggregateField is not defined

I'm new to Retool, and I'm trying to perform a basic Aggregate Sum function on my Firestore Collection as follows:

const gigsRef = db.firestore().collection("gigs");
const sumAllShiftsPosted = gigsRef.aggregate({
  totalShiftsPosted: AggregateField.sum("numSpotters"),
const snapshot =  await sumAllShiftsPosted.get();

I'm getting the following error:
'AggregageField' is not defined

What am I missing? Does Retool not support aggregate functions? If so, how do I achieve the result I expect above?

Hi @ikartik90, I don't believe Firestore supports aggregation queries natively in the way you're trying to use it in the code pasted above- I don't see the aggregate method or an AggregateField class in it's JavaScript SDK which is likely why you're seeing that error. However, you should be able to achieve your goal of summing up 'numSpotters' in you 'gigs' collection by creating a javascript transformer that loops through the documents and sums up the numSpotters. Something like this should work:

let data = {{}}; 
let totalShiftsPosted = 0; 
for (let i = 0; i < data.length; i++) { 
   totalShiftsPosted += data[i].numSpotters; 
return totalShiftsPosted;