Conditions

Hi guys,

Need some help please.I don’t have any coding experience but i use the below code and it works fine. When users inputs the exact value that’s in the database, my table displays it.
What i would like is to add some “conditions” to my code.
If form (#input1) is blank, return message “please input title”
If value doesn’t match with the database, return the message “No titles found”

import wixData from ‘wix-data’;
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
$w.onReady( function () {
//TODO: write your page related code here…
});
export function searchButton_onClick(event) {
wixData.query(‘MyDatabase’)
.eq(‘Title’, $w(‘#input1’).value)
.find()
.then(res => {
$w(‘#table2’).rows = res.items;
$w(‘#table2’).show();
});
}

Hi Florin,

Welcome to the Wix Code forums.

You can look at the wix-data query API for details and examples on creating database filters.

A gentle warning: What you want to do will be a bit challenging for a beginning coder. But, not impossible. Use the on-line documentation and resources to find out what and how, and we’re always here to help get you pointed in the right direction.

Good luck and have fun,

Yisrael

Thank you