Cant filter calculated sums from database by _owner or current logged in user

Hi Everyone.

Need some help here. I have a database that shows the values of items in each storage locker.
User’s input their values into the storage lockers that they own, they should only be able to see and calculate fields from their own input data, not other members.

I calculate the total sum of each storage locker and send the results to a text element on the page.

This works fine however all users no matter who is logged in can see the results so it doesn’t just show their own items but everyone’s items in the calculation.

The dataset is already set to current user logged in only and if I select any of the elements in the database it will only show that user’s data on the page, however the problem is when I query the database it will calculate "everyone’s data and not just the logged in user.

Here is a snippet of my code:


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

const filter = wixData.filter().contains("location", "storageLocker1")
wixData.aggregate("StorageLocations")

.filter(filter)
.sum("itemValue", "sumS")
.run()
.then ((result) => {
var itemValue = result.items[0].sumS
$w('#sumS').text =  "$" + itemValue.toLocaleString();
 
})

So basically the database is like this:

and the filter is set to current user logged in:

The calculation works fine, but it’s not filtering by the current user logged in, it calculates using all the of user’s inputs. I have already set the dataset filter to user logged info only but that only filters non calculated fields, while calculating fields all user’s inputs are entered in the sum calculation output.

Is there anyway to query the database using the calculation fields AND the current user ID that is logged in who made the query?

Any help or insight what to do here would be great.