Search, display and add a value to a DB

I have a DB and I want to create a form to update some fields about a costumer.
First I want the user to search for the item and to display the details of the costumer.
the search can be by two options: Clint number(uniq) or client name (show me options by predicting )
the search requires a press on a search button.

  1. If a match is found: show me the details of the costumer (name, address, etc’)
  2. If no match is found: Show a message “there is no costumer with these details”

In addition I will display an option for some fields that I want to update regarding the costumer
They will be updated with an “update” button,

Example

Thanks
Yossef Bar

Hay Yossi,

What you should do is use a dataset in the read/write mode.
To have the search working, write code that sets the dataset filter . Once you set the filter, the dataset will load the first element that matches the filter, or non if no item is found. Your user can, at this time, modify the found item. To save it back to the database connect a button to the save action or just call the save API of the dataset.

Thanks
How do I connect the dataset filter to a button?

Hi Yossi,

You can nest the set filter code inside the button click event as follows:

//'filterBtn' button is present on the page, a click event by the name of 'filterBtn_click' was added
export function filterBtn_click() {
	$w("#dataset1").setFilter( wixData.filter()
  .startsWith("name", "dave")
  .ge("age", "21")
)
.then( () => {
  console.log("Dataset is now filtered");
} )
.catch( (err) => {
  console.log(err);
}