I am trying to replicate what would be a left join in MySql in Mongo. I have a collection named Clients and another collection name Orders.
In the clients collection is have:
client_PK, FirstName, LastName, Company
In the orders collection I have:
order_PK, client_fk, OrderDate, OrderAmount,
So i know that can use embedded documents but for the sake of this question i am looking to use the reference model.
My question is, using these two collections how would I construct a table or object similar to a left join in mysql? I know this is a document db not a relational db but im using sql language just to give you an idea of what im trying to accomplish. In MySql it would look like this:
SELECT * FROM orders LEFT JOIN clients ON clients.client_PK = orders.client_fk
with this i could now construct a table that looked like:
FirstName | LastName | Company | OrderDate | OrderAmount
then i could repeat the rows using a while loop to display all orders and display the clients name with the order. Again i know mongo isn't a relational db but i am assuming there is a way simulate a table using two collections.
Thank you.