I have two DB tables: entities and events .
in entities, I have a Reference type field, named eventId , to the events table.
in events, I have a Text type field, named name .
I want to query something like this:
wixData.query("entities").include("eventId")
.eq("type",type).eq("eventId.name", inputName).find().then((lines) => {
// SOME CODE
}
to be clear: I want to get a specific entity line that fits a specific type & event’s name.
You can try to query first the events DB to get the id of the item matching “inputName”. Once you get the id, use that id to perform a second query “entities” and match the “eventId” reference field.
wixData.query("events")
.eq("name", inputName)
.find()
.then((res)=>{
let firstItem = res.items[0];
let selectedKey = firstItem._id;// selectedKey store the id of the "events" item
console.log(selectedKey)
wixData.query("entities")
.eq("type", type)
.eq("eventId", selectedKey )
.find()
.then((lines)=>{
// SOME CODE
})
})