Hi! I have have a dataset that is connected to a collection which contains a number of fields. Some of those field are arrays of objects. The following snippet shows the “members” field of my collection for one specific row of my collection. Each row contains a similar array of objects.
[
{
"Scores": {
"Tastes": {
"characteristics": {
"colors": [
0
]
}
},
"bodyType": -3,
"brand": -3,
"ItemType": 0,
"seasonalType": -3
},
"Match": 70,
"userId": 1
},
{
"Scores": {
"Tastes": {
"characteristics": {
"colors": [
0
]
}
},
"bodyType": -3,
"brand": -3,
"ItemType": 0,
"seasonalType": -3
},
"Match": 80,
"userId": 2
},{
"Scores": {
"Tastes": {
"characteristics": {
"colors": [
0
]
}
},
"bodyType": -3,
"brand": -3,
"ItemType": 0,
"seasonalType": -3
},
"Match": 75,
"userId": 3
},{
...
}
]
I also have a repeater that is connected to this dataset. In case site member X with a certain userId visits my page, I want to display those repeater items with the best match first. Imagine for a second that member X has userId equal to 1. This means I need to look at members[0] for each row in the collection to get the match, hence members[0].Match.
Now I would like to tell my repeater to display its items in a descending order, starting from the item that has the largest Match. For that, I’d have to sort all the items in my collection based on the values that are stored in members[0].Match on each row. This would result in something like:
function sort() {
var newSort = wixData.sort().descending("members[0].Match");
console.log(newSort);
$w("#dataset1").setSort(newSort);
}
Unfortunately I can only work with members.Match and not with specific indices. Is there a workaround? @J. D. we talked about this before, so maybe you can shed some light on this? See: https://www.wix.com/velo/forum/community-discussion/wixdata-filter-for-data-field-containing-array-of-objects
Thanks!