Saving database column parameter into variable

Hi, Can i look for database column and save it into parameter so i can use it in the rest of the code?
for example, i have database with id of “database1” and column called “column2”
i want to get all the data from “column2” saved into array variable and then use it at different place in the code, i saw some examples but didn’t manage to make them work and most of the times the parameter in inside a lambda executed coed and i’m not sure how to extract it

Thanks!

import wixData from 'wix-data';

var myNewParameters

$w.onReady(()=>{
    wixData.query("YourDataCollectionNamehere").find()
    .then((res)=>{
        myNewParameters = res.items
    })
    
    $w('#myBotton').onClick(()=>{
        console.log(myNewParameters)
        console.log(myNewParameters[0].title)
    })
})

Thanks a lot !

@adig1989 :wink: Good-luck & happy coding.