How can I query two collections with include and .eq() on the second collection

Hello,

I’ve a problem I want to query with joined collections. for that I’m using the .include()

first collection: personalInfo
second collection: details

“details” has a refernce field to “personalInfo” collection

I’ve selectionTags for the details collection, now I want to add another condition that will apply on the “personalInfo” collection and give me the joined results

so if for example I’ve:
“personalInfo” : {firstName: “fibi”, lastName: “more”, age: 25, email: “email@gmail.com”}
"details’ : {status: “active”, startDate: 14/05/2022, }
and I want to get all of the items from the details collection with “active” status with firstName of “fibi” from the personalinfo collection, how can I do so?

on the below code the .eq() doesn’t work on the personalInfo collection

wixData.query("details")
            .include("uniqId")
            .hasSome("type", selectionTags) //apply on the "details" collection 
            .eq("firstName" , name) // apply on the "personalInfo" collection 
            .find()
            .catch((error) => {
                console.error(error + " filltered by: " + selectionTags);
            });

Thank you!

If the uniqueId is really unique, then you don’t need to query the personalInfo for “fibi” (becuase the uniqueId stands for the Fibi user).
All you need is to replace your .eq(“firstName” , name) by .eq(“uniqId” , uniqId) and to remove the .include.