Hi, so I came across multiple posts on this topic. But either they are too old or not completely relevant. I have a members collection, which has all the basic info for my users. Then I have another collection events with event details. Finally I have reservations collection, which has users linked to events. I want to query details of the events for which the logged in user has made a reservation. A 2017 post seems to suggest that this feature did not exist before and now is developed. Can someone please help?
Hi syd8uf. I had the same problem and came across http://www.wix.com/code/reference/wix-data.WixDataQuery.html#include , which seems to perform a table join (very non-intuitive name, I agree). I hope this can help you
Thanks for this. I will go through the same.
hi, I tried to use the same, but it asks me to reference specific items. I want to create a field to field reference. Is that possible?
Hi
Do you have a reference field to the relevant event in the reservations collection? If yes, you can search the reservations collection by providing the event _id to the query.
wixData.query('reservations').eq('event', event._id).find();
And that assumign that you have a field called “event” referencced to the events collection.
How do I create a referenced field? I am trying to figure that out. Not able to get it from the documentation. Do I need to manually create the referenced field or can I do through code?
@syd8uf Just open the collection in the editor, select the (+) sign to add a field, and on the field type, select ’ referenced ', then select the events collection.
Thanks a lot for this, Ahmad!