I have created a daily crop quantity database for 2 different areas (A & B) as shown below.
I need to get the sum of each daily crop quantity as Total Crop in the month end, Area wise (For A & B).
So I used below code on “Total crop page” to change #text9 according to the database.
But its not working.
import wixData from ‘wix-data’;
$w.onReady( function () {
wixData.query(“CropEntry”)
let filter = wixData.filter().eq(“area”, “A”);
wixData.aggregate(“CropEntry”)
.filter(filter)
.sum(“cropQty”, “sumcropQtyA”)
.run()
.then( (results) => {
if (results.items.length > 0) {
let items = results.items; // see below
let numItems = results.length; // 1
let hasNext = results.hasNext(); // false
console.log(results.items);
$w(“#text9”).text = items.toString();
} else {
// handle case where no matching items found
}
} )
. catch ( (error) => {
let errorMsg = error.message;
let code = error.code;
} );
})
Appreciate your great help on this <3.
@ziv-shalev