Hi I have created a search that works on strings values with in my db but when I try to use it on a number filed it doesn’t work
Here is the code:
export function voter_change() {
wixData.query(‘ofakimT’)
.contains((‘VoterNo’).toString(), ($w(‘#num ’).value).toString())
.find()
.then(res => {
$w(‘#table1 ’).rows = res.items;
});
}
as you ca see I have tried to add a string cast but with no success.
Thanks
Yossi
_tal
December 14, 2017, 12:48pm
2
Hi Yossi,
It seems like you haven’t defined the “VoterNo” variable. If this variable is a global variable, you should use
VoterNo.toString( ) instead (without using brackets).
Moreover, if the DB collection value is a number and not a string, you should use the following code:
wixData.query("myCollection")
.eq("fieldName", $w('#num').value)
.find()
.then( (results) => {
$w('#table1').rows = results.items;
} )
.catch( (err) => { let errorMsg = err; } );
Click here to learn more about the query function.
Have a good day,
Tal.
How do I define a global variable in wix?
Hi,
To define a global variable simply add it in the global scope, meaning:
//this is a global variable
let globalVar = '123';
function doSomething() {
//this is not a global variable
let notAGlobalVar = '456';
}
Tanks
What I wanted to know is how to define a global var that represent a column in my DB