Dear all,
I am trying to learn how to use query instead of filtering, as this would be a more flexible way for me to analyze the results. Again, I am a beginner Velo/java, I read everything I could find but beside the general structure of query to repeater I still have some questions. This is the example code I am basing myself off (sorry it’s a screenshot, but for some reason copy paste in a code section looses all the formatting, this is the link to the useful post I looked at: https://www.wix.com/velo/forum/tips-tutorials-examples/how-to-display-your-database-content-in-a-repeater )
My questions are multiple:
-
If I defined and connected the repeater structure to the dataset through the editor graphical interface, does it still work? Do I have to start from scratch and define all the items of the repeater in the coding as well? Do I have to define only the ones affected by the query function? Like my database have 10-12 columns, but the repeater display data from only three or four of them.
-
How do I match the query results to the correct field in the repeater? I cannot find a place where all the items that come out of the query are defined. In other words, if the query gives me 10 results out of a database, those results are associated to 10-12 different columns, where and how that information is stored?
I guess that for point 2, what I am referring coul be clear from the following code (from velo api). HEre I am running a query and then the console shows me the first results, that has several values associated. I I want to refer to one of those values from all the results of the query, which syntax should I use? For example in the code here, I would like to have the results 1-10 (so I guess results.items[0,9] but retaining only the “_id” value… how do I recognize and see/save those values?
import wixData from 'wix-data';
2
3wixData.query("myCollection")
4 .include("city")
5 .find()
6 .then((results) => {
7 let firstItem = results.items[0]
8 console.log(firstItem);
9 });
10
11
12 /* firstItem is:
13 *
14 * {
15 * "_id": "1d8a1d97-93d3-4d6c-9a0f-c279058b4aa5",
16 * "_owner": "81c9168e-95b8-47fd-8e6a-ad9fdf71b38e",
17 * "_createdDate": "2020-08-03T10:26:26.825Z",
18 * "_updatedDate": "2020-08-03T10:27:01.558Z",
19 * "first_name": "Betty",
20 * "last_name": "Boop",
21 * "city":
22 * {
23 * "_id": "a99daca6-0400-4ef1-8d74-de3f9095bf0b",
24 * "_owner": "81c9168e-95b8-47fd-8e6a-ad9fdf71b38e",
25 * "_createdDate": "2020-08-03T10:22:39.114Z",
26 * "_updatedDate": "2020-08-03T10:23:25.042Z" ,
27 * "city_name": "Los Angeles",
28 * "state": "California"
29 * }
30 */
I really hope someone could help me and sorry if the lingo is rough!!
Best,
Marco