(If I didn’t misunderstood, in a nutshell what you said was: do your calculation, save it in the database and let it be shown in your repeater,) And yeah, that’s the best I can do in this situation
Abssolutely correct!
You must always imagine, that your repeater is working with the following structure…
ARRAY including several OBJECTS, which looks for example like…
[
{
"_id": "1",
"firstName": "John",
"lastName": "Doe",
"image": "http://someImageUrl/john.jpg"
},
{
"_id": "2",
"firstName": "Jane",
"lastName": "Doe",
"image": "http://someImageUrl/jane.jpg"
}
]
All these informations you are able to find inside the REPEATER-INTRODUCTION.
Everytime when you are working with an -->ÁRRAY–> you should know, that it is very easy to loop through an → ARRAY.
What is an ARRAY and how is it constructed???
let myArray = []; <-- here you are defining your new ARRAY.
Now, how we can fill an ARRAY with data?
There are several options to do that, for example…
myArray.push("newValue")
RESULT would be —>
["newValue"]
Let’s add another value to the Array…
myArray[1] = “xxx”;
RESUT —>
["newValue", "xxx"]
As you can see, i used two different methods to fill the ARRAY.
But what you need is to loop trough an ARRAY and for this you also have different options, by using for example a for-each-loop or an ordinary for-loop, or maybe even a while-loop.
Let’s use a for-each-loop.
myArray.forEach((element)=> {
console.log("Element: ", element);
});
So if your ARRAY do have the followind data–> [aaa, bbb, ccc, ddd, eee, fff, ggg]
…and you would do the loop shown above???
What you would get inside of your console? Right, you would get…
aaa
bbb
ccc
ddd
eee
fff
…because it would loop through all the given data inside your ARRAY and you would get a console.log for each of the item-data inside the ARRAY.
So now try to do the same, but this time you will have → OBjeCTS inside your ARRAY ← it will be exactly the situation what you need, because a REPEATER and also the Wix-Data-query is working with such a data-format.
Try to loop through this data-array-object…
[
{
"_id": "1",
"firstName": "John",
"lastName": "Doe",
"image": "http://someImageUrl/john.jpg"
},
{
"_id": "2",
"firstName": "Jane",
"lastName": "Doe",
"image": "http://someImageUrl/jane.jpg"
}
]
… and try to get all the —> firstNames <— only.
But normaly you do not have to do all these steps, because all what you need, should already be inside the RESULT-DATA, you get from your query.