Filter sum with database

Hello,

I’ve managed to get the following code to work, I am just struggeling with adding 2 filters. The code that have working is;


import wixData from 'wix-data';
$w.onReady(function () {

wixData.aggregate("SEGMENTS")
.sum("price", "totalsum")
.run()
.then((result) => {
var stock = result.items[0].totalsum
$w('#text236').text = stock.toString()
})
});

What it does, is summing the value in the price columns of all database rows of the SEGMENTS database.

Ideally, I would like to add two filters:

  1. The value of column “STATUS” is “NEW”.

  2. The value of the reference field in column “itineraryId” contains the same value as database, like in this filter:

Does anyone have any idea how to add these two filters?

Thanks so much!

Best regards, Stefan