I need to know that how I can use the reference key in my code if want to add a search query.

wixData.query(‘Poperties’).eq(‘transactionType’, $w(“#dropdown1”).value)
.or(wixData.query(‘Poperties’).eq(‘loanType’, $w(“#dropdown2”).value))
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
});

here is my code. Where loanType is the reference key which I got from the other table but dont know why it is not working. wixData.query(‘Poperties’).eq(‘transactionType’, $w(“#dropdown1”).value) that is working fine but but other is not working please guid me where I am doing wrong thanks

You need to add in your query

.include('referennceField')

where I need to add that in my code please guide

Please reply

 by including that code 
 
 (wixData.query('Poperties').eq('transactionType', $w("#dropdown1").value)).include('loanType')
.find()
.then(res => {
$w('#repeater1').data = res.items;
console.log(res.items);
});

I am getting that

  1. “{"state":"dd6a2d7c-6c40-4071-85a2-4bef779cfd79","_id":"46d01483-9541-4c8d-8e69-a885decbae92","_owner":"2bff55a3-d1b6-4c1b-8abf-f0c46a796974","_createdDate":"2020-03-20T15:59:15.836Z","price":"453333211","propertyType":"e3d5fedc-112a-4980-8da9-9797e28ace59","transactionType":"cheque","_updatedDate":"2020-03-20T16:22:28.739Z","companyName":"test5","title":"5","loanType":{"_id":"854cccf6-3037-43d5-ab2e-c5dafa154243","_owner":"f09c7e52-9e28-4a7c-b302-9e0309b4198d","_createdDate":"2020-03-03T19:38:48.625Z","_updatedDate":"2020-03-03T19:38:48.625Z","title":"Office "}}”
    0:

  2. “{"state":"255dbd6c-95ce-431b-b407-55e66f5be3b1","_id":"ca95b24a-37cc-4aad-b41c-261ac43e9828","_owner":"2bff55a3-d1b6-4c1b-8abf-f0c46a796974","_createdDate":"2020-03-20T10:15:54.894Z","price":"3500000","propertyType":"dfed6684-e094-4238-a023-7bbcdb4588cd","transactionType":"cheque","_updatedDate":"2020-03-20T16:22:21.158Z","companyName":"Test abc","title":"1","loanType":{"_id":"c7af8892-b867-4a9f-99f7-b88c6d3dcc7b","_owner":"f09c7e52-9e28-4a7c-b302-9e0309b4198d","_createdDate":"2020-03-03T19:38:48.629Z","_updatedDate":"2020-03-03T19:38:48.629Z","title":"Single Family Home"}}”
    1:

How I can add .equal query to a reference field which I am including?

Please any one help me

literly saying no one is for help there

As per our forum guidelines please stop bumping up your thread every few hours as it will not get answered any quicker.

Also note that most of Wix won’t be working Saturdays anyway so you might not have got a reply until Sunday when Wix return to work in some regions.

When you add the include function to your query for referenced fields, then that is what is returned to you.

See this old post for more info.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/api-addition-wix-data-include-for-reference-fields

If you had searched the forum instead of bumping up your thread, you could have found previous posts like these.
https://www.wix.com/corvid/forum/community-discussion/query-many-collections-with-reference-fields

You can read more about it in the Wix API Reference as well.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#include
https://www.wix.com/corvid/reference/wix-data.html#queryReferenced

You can have a look at this example here too.
https://www.wix.com/corvid/forum/community-discussion/example-wix-data-multiple-references

I am not bumpnig over my post. I have checked all the links you mentioned but I also attached the code the I treid I saw that. I ask you for help.
(wixData.query(‘Poperties’).eq(‘transactionType’, $w(“#dropdown1”).value)).include(‘loanType’)
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
console.log(res.items);
});
here is my code that I already attached you dont replied my query just posted the links from the documentation.

.eq query works with reference field also. Are you sure you are passing the correct values to .eq query?

yes I am sure values are right. According to you my code should work?

Try something like this…

import wixData from 'wix-data';

$w.onReady(function() {
$w("#dataset1").onReady(function () {
});
});
wixData.query('Poperties')
.eq('transactionType', $w("#dropdown1").value)
.include('loanType')
.find()
.then(res => {
$w('#repeater1').data = res.items;
console.log(res.items);
});

@givemeawhisky sure I will try this and let you know what is the reuslt thanks for your reply :slight_smile: