I'd like to combine multiple rows of repeating Stock Counters into a single row and also sum up the Volumne and Price of the combined items so they are stored and displayed to the React Admin list.
Screenshot of the current list of items
The output of the below screenshot is run by the below code
try {
const m = await Portfolio.find({}).populate({ path: 'customer', select: 'firstname', model: 'User' }).populate({ path: 'stockItem', select: 'Counter', model: 'Stock Items' }).exec();
return res
.setHeader('Access-Control-Expose-Headers', 'X-Total-Count')
.setHeader('X-Total-Count', Object.keys(m).length)
.status(201)
.json(m);
} catch (err) {
// eslint-disable-next-line no-console
console.error(`${err}`);
return res.status(400).json('Failed to either retrieve nor create a Transaction. Kindly retry again.');
}