Help using aggregates error sum() run()

Good afternoon first of all, I’m trying to use the function to sum the values ​​of a column of the content manager, but when executing the code I get this error

export function Sum_Buenas ( ){
var idproy = $w ( ‘#text9’ ). text ;
const filter = wixData . filter (). eq ( “IDProyecto” , idproy );

wixData . aggregate ( “MYSQL/RepSerial_tbl” )
. filter ( filter )
. group ( “IDProyecto” )
. sum ( “BUENAS” , “totalBuenas” )
. run ()
. then ( ( result ) => {
var totalB = result . items [ 0 ]. totalBuenas
$w ( ‘#text37’ ). text = totalB . toString ()
})
. catch ( ( error ) => {
let errorMsg = error . message ;
let code = error . code ;
})}

this is the error

  1. I’ll assume you import wixData, If not - you should do it
  2. I’ll assume you call this function from $.onReady and inside dataset.onReady if the text is retrieved from data collection. If not - you should do it.
  3. You’re using field labels instead of field keys. Field key never starts with a capital letter.
  4. No need to use ‘export’.