I can’t figure out how to get field values from joined collections. How do you do this in wixData.Query( ) and in $w(“#myDataset”).setFilter( ) scenarios?
It looks like ‘_items’ collections that are returned hold a ‘ref’ field with an internal primary key to the referenced collection, but I do not know what to do with that?
Hi,
That ref is “_id” field of the item in the referenced collection.
You can use wixData.query(“nameOfCollection”).eq(“_id”,the ref that you received).find()
And then you get the item from the referenced collection.
Roi
This is somewhat helpful - thank you. However, I am still struggling. I have 2 collections: ProgramTypes and CoursePrograms. ProgramTypes is a lookup collection. CoursePrograms has a reference back to ProgramTypes (via a Reference field named ‘Program’). My code has the ‘_id’ from the ProgramTypes collection already. Now, I need to query the CoursePrograms collection where the Program.ref = [my _id].
var id = “ABC123”; //_id from ProgramTypes
wixData.query(“CoursePrograms”).eq(“program.ref”, id).find();
This does not work. How can I get this working?
Thanks!
I checked it out and it doesn’t work, i’m afraid it is because the setFilter function doesn’t work on reference fields, I will give you an answer soon.
You are searching for a solution?
Then you should perhaps open an own new post with your own topic.
Who is that bad guy who do not want to help?
Do you mean the post-writer above you, which already are gone or even dead by CORONA-VIRUS? (JOKE)
Take a look at the date, when the last post was released.
You will wait for month or even years, for an answer, because none of these persons are still here (perhaps).