Hi, could someone help with my query. When the user fills in a word and click search, the query should search for a identical match in the database. I already tried several options but they all failed. When succeeded, the user should see a message "OK", when not succeeded, they should see a message "Nothing found".
This is my code, I tried several alternatives but they all failed. Thanks in advance for the help.
iboxcode: name of the input box
Boxcodes: name of the database
title: name of the colomn where the query has to search
resultbox: the text box that should contain the message for the user
import wixData from "wix-data"; export function Claim(event) { wixData.query("Boxcodes") .eq("title", $w("#iboxcode").value) .find() .then(res => { $w("#resultbox").value = res.items; }); }
CAN WE DO THOSE WITH .EQ FOR BOTH UPPER AND LOWER CASE?
I DONT WANT TO USE .CONTAINS
THX
If that doesn't work, do this - >
wixData.query("Boxcodes") .eq("title", $w("#iboxcode").value) .find() .then( (results) => { if(results.items.length > 0) { let item = results.items[0]; $w("#resultbox").value = JSON.stringify(items); } else { // handle case where no matching items found } } )
(Matching strings with eq() is case sensitive, so "text" is not equal to "Text".)
Hey, try this ->
wixData.query("Boxcodes") .eq("title", $w("#iboxcode").value) .find() .then( (results) => { if(results.items.length > 0) { let items = results.items[0]; $w("#resultbox").value = items; } else { // handle case where no matching items found } } )
(Matching strings with eq() is case sensitive, so "text" is not equal to "Text".)
Levi, Javascript/Wix Code is case-sensitive. I'm wondering if the collection "Boxcodes" is actually lower case "boxcodes". A query will return nothing, even when it seemingly should, if that is not correct.