Retrieve data from database when the email is match

Here is my database.

Here is my page. The “Enter your email” is called “input1”, and the “Show Amount” is called “input2”.

My question is is that possible when my member enter they email at “input1” then “input2” will automatically show the correct number?

How to retrieve data from database when the email is match?

Anyone help me?

Just use Wix Data Query with the eq function to get the matching email etc and get the users amount from the appropriate field of your dataset.

Sir can you show me an example? I am new in wix code

I try the code as below but it didn’t work.

wixData.query(“Wallet”)
.eq(“email”, )
.find()
.then((results) => {
console.log(results);
if (results.items.length > 0) {
let Item = results.items[0];
console.log(Item);
$w(‘#input2’).value = Item
}
})
The “input2” is empty didn’t show any thing.

The Query function for eq needs to contain your field and value that you are trying to find that equals your search.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#eq

As you are looking for a email which is not static and is variable, then you need to define it before the search itself.

You will also need to add a simple button to your page so that the user can click on it to run the search etc.

Something like this.

import wixData from 'wix-data';

$w.onReady(function () {

let emailValue = $w("#input1").value;

export function searchButton_onclick(event) {
wixData.query("Wallet")
.eq("email", emailValue)
//rest of code....

Thank you sir! The code is work. But the “input2” is still empty.

I try to change the database field type from number to text and change the code
$w(’ #input2 ').value = Item
From .value to .text
But the “input2” is still empty.

When i preview i can see the code working it does have found the record but cannot display at “input2”