Managing database entries

Dawd

To search a database for records with multiple property values you effectively need to AND together query tests like .eq() and .gt() . These functions return a query as the result which can then be used to add subsequent tests.

So for example in your case you want to find a matching email and password. If the data collection is called “Members” then your query code would look something like this:

wixData.query('Members')
.eq('email', email)
.eq('password', password)
.find()
.then((results) => {
     // If no records are found then the result totalCount will be zero
     // Otherwise there is a record and it is returned in the items array
     if (results.totalCount === 0) {
         // Set error condition
         throw Error("No record with the email and password given were found");
     } else {
         // Success - get the first record in the array
         // You need to decide if having multiple records with the
         // same email and password makes sense (probably not!)
         let foundRecord = results.items[0];
         
         // Do something with foundRecord...
     } 
});

The result returned by find is a queryResult which contains a variety of useful info.

Hope this helps
Steve