in my database, i have proj1, proj2 ... up to proj10.
is there any possibility to query base on the number
$w.onReady(async function () {
var myDatabase = "allProject"; var usernameField = "username";
let up = $w('#username').text; let no = 1; getProjName(myDatabase, usernameField, up, no)
}
async function getProjName (myDatabase, usernameField, user, no) { return wixData.query(myDatabase).eq(usernameField,user).find().then((results) => { let items = results.items; let item = items[0]; return item.pro[no]; }) }
found a solution to this. so sharing just incase anyone have the same query
$w.onReady(async function () {
var myDatabase = "allProject";
var usernameField = "username";
let up = $w('#username').text;
getProjName(myDatabase, usernameField, up, no)
.then ((item) => {
console.log(item.proj1) //change if you want others
}
}
async function getProjName (myDatabase, usernameField, user, no) {
return wixData.query(myDatabase)
.eq(usernameField,user).find().then((results) => {
let items = results.items;
let item = items[0];
return item;
})
}