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?
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');
});
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.
@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.