setting variable value from data base collection

i need to create a variable in the page code (a,b,c,d) that gets the value from the data base ‘collection’
import wixData from “wix-data”
wixData.query( ‘collection’ )
.find()
.then(res => {
let a = res.items; let b = res.items; let c = res.items ; let d = res.items
let dataitems = {data:[ a , b , b , d ]};

how to query a specific cell in the the ‘collection’
so a will be set with the value from a specific cell in the collection

See the WixDataQuery API for information on database queries.

Hi Israel, i spent long time reading this and the post there is no reference how to get the value of a specific cell (like column 2 raw 4) based on position and not based on the cell actual value (like in the case of .eq) can you please help on this

A database collection isn’t organized as cells in rows and columns, but rather as items and fields. In order to access “rows” (items) by position, you will need to define a field that specifies the “row” position (1,2,3,4,…) and fields that will be your “columns”. A database query that specifies the desired “row” will get the collection item that is your “row”, and the fields that you defined as “columns” will be available as fields in the item returned from the database query.

This will require the database collection to be appropriately designed, and you’ll then need to write the code required to get your “rows” and “columns”.

Keep in mind that a database collection is not a spreadsheet.

thanks Yisrael.
i was able to get the collection data to the page code with the following code
however it is still not working. is there a way to set the retrieved array as a comma separated variable so conservative=18,30,8,8,21,13
thanks

import wixData from “wix-data” ;
$w.onReady( async function () {
const chartItems = await wixData .query( “mycolletion” )
.find()
.then(res => res.items);

const conservative = chartItems.map(item => Number(item.conservative));
const moderate = chartItems.map(item => Number(item.moderate));
const agresive = chartItems.map(item => Number(item.agresive));

let styles = {

    conservative: [{conservative}],  

//////// should be conservative: [{18,30,8,8,21,13}],
};

console.log(conservative)

Array(6)
0: 18
1: 30
2: 8
3: 8
4: 21
5: 13

Once you have the array, just build the comma separated string with a little Javascript.