Hello,
This code below creates two WIX queries perfectly for me:
// Get ALL Menu Items --------------------------------------------------------------------
// Returns 20 rows with fields: _id, title, photo, description, menu, etc...
let myMenuItemsQuery = await wixData.query("MenuItems")
.find()
// Get WishList Items for this User ------------------------------------------------------
// Returns 3 rows for current user with fields: _id, userId, menuItem (reference field)
let user = wixUsers.currentUser;
let myWishlistQuery = await wixData.query("Wishlist")
.eq("userId", user.id)
.include('menuItem')
.find()
// How do I JOIN these into one query that I can use to populate a repeater? ------------
// Display Query Results ----------------------------------------------------------------
console.log("***** Menu Items ", myMenuItemsQuery)
console.log("***** Wishlist Items ", myWishlistQuery)
Now I need to JOIN them such that I get:
* ALL items in myMenuItemsQuery (20 items in example)
* JOINED to myWishListQuery (filtered for current user) on menuItem._id
* so that I can tell which items in the myMenuItemsQuery are on the wishlist
An example is that:
* Menu Item “Blueberry Pie” has an _id = 1064e51c-8874-40dc-ac6b-88d41f8cd51d
* MenuItems._items._id = 1064e51c-8874-40dc-ac6b-88d41f8cd51d
* Wishlist._items.menuItem._id = 1064e51c-8874-40dc-ac6b-88d41f8cd51d
Ultimately, I need a query with ALL menu items and then a flag to tell me if that particular item is in the user’s wishlist.
How would I go about creating this join?
Thanks, Jason