search function error, can anyone help?

Here is my testing page
www.greatinfohk.com/testing3

database: agentprofile

and the coding below

import wixData from ‘wix-data’;

//For full API documentation, including code examples visit http://wix.to/94BuAAs

$w.onReady(function(){
//TODO:import wixData from ‘wix-data’;
});

export function button30_click(){
wixData.query(‘agentprofile’)
.contains(‘saving’,$w(‘#dropdown1’).value)
.contains(‘termlife’,$w(‘#dropdown1’).value)
.contains(‘wholelife’,$w(‘#dropdown1’).value)
.contains(‘ci’,$w(‘#dropdown1’).value)
.contains(‘hs’,$w(‘#dropdown1’).value)
.contains(‘accident’,$w(‘#dropdown1’).value)
.find()
.then(res=>{
$w(‘#table1’).rows=res.items;
});
}

Hey,
I would try using the eq( ) instead of contains( ) function when searching your DB collection.
Moreover, please make sure that you copied the field keys correctly.

Tal.

Hi Tal,
still not work even with changing to eq() and correct to match with field keys…
What’s else step can fix it work?

I would use console.log(res) to check if you get the results.
Should the issue persists, please send the site URL and the name of the page to which the code was added so that we can have a look.

Tal.

here is the URL
www.greatinfohk.com/testing3

And the coding was inserted here: testing3
thanks

Waksman

Hi Waksman,

Use the following syntax to chain multiple queries:

  wixData.query('collection1')
  	.or(wixData.query('collection1').contains('title', $w('#nameInput').value))
  	.or(wixData.query('collection1').gt('age', $w('#numberInput').value))
  	.or(wixData.query('collection1').lt('age', $w('#numberInput').value))
  	.find()
  	.then(res => {
  		console.log(res);
  	});
  }

I’m the beginner and please have a look if this is correct

wixData.query(‘agentprofile’)
.or(wixData.query(‘agentprofile’).contains(‘saving’,$w(‘#dropdown1’).value)
.or(wixData.query(‘agentprofile’).contains(‘termlife’,$w(‘#dropdown1’).value)
.or(wixData.query(‘agentprofile’).contains(‘wholelife’,$w(‘#dropdown1’).value)
.or(wixData.query(‘agentprofile’).contains(‘ci’,$w(‘#dropdown1’).value)
.or(wixData.query(‘agentprofile’).contains(‘hs’,$w(‘#dropdown1’).value)
.or(wixData.query(‘agentprofile’).contains(‘accident’,$w(‘#dropdown1’).value)
.find()
.then(res=>{
$w(‘#table1’).rows=res.items;
});
}