DataBase Query

Hello, i would like to use the information collected from my database and assign it to a variable in my wix code, however when i do a wix query, it returns an array when i would like the value of one specific box in my database as a string. can anyone help?

this is my code:

var hello = 0
    $w("#text18").text = hello.toLocaleString('en');
    wixData.query("Test")
        .find()
        .then((results) => {
            console.log(results.items);
            hello = results.items
            console.log(hello);
        });
    $w("#text18").text = hello.toLocaleString('en');

I haven’t attempted to do what i’ve asked above because i couldn’t find anything relevant in the corvid forums.

See:
https://www.wix.com/corvid/reference/wix-data.html

var hello = 0
    $w("#text18").text = hello.toLocaleString('en');
    wixData.query("Test")//collection name
        .eq("certainFieldKey", "myString")//value in collection is equal to value
        .distinct("certainFieldKey")
        .then(r => {
            hello = r.items[0];
            $w("#text18").text = hello.toLocaleString('en');
        });
    

thankyou for responding!

i will try it out

I used your code and im still getting the same result

// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixData from 'wix-data';
export function button1_click(event, $w) {
    $w("#text18").text = hello.toLocaleString('en');
}
var hello = 0

$w.onReady(function () {
    $w("#text18").text = hello.toLocaleString('en');
    wixData.query("Test") //collection name
        .eq("certainFieldKey", "myString") //value in collection is equal to value
        .distinct("certainFieldKey")
        .then(r => {
            hello = r.items[0];
            $w("#text18").text = hello.toLocaleString('en');
        });

});

Is there something i’ve done wrong, if so please tell me.

thankyou for helping

Harry

@henrybarea you need to change the first “certainFieldKey” to the field key you want to compare. the “myString” to a string or number (or any value) you want to compare to, and the second “certainFieldKey” to the field key of the value you want to get.

@jonatandor35 I’m sorry if you misunderstood me but I wanted to change a variable to a submission in my form not compare items already in the database.