Hello internet, today I would like to give a little information on a misconception with MongoDB. NoSQL explicitly denounces relational queries as a thing of the past, however it is necessary to normalize your data and keep it efficient and avoid having duplicate information.
For my discussion today, I will refer to vendors permissions, which was for a sample purchasing app I demoed inside portalstack.
To do a relational look up, you need to do a bit of async programming. For me, I used the async library provided by the nodejs community.
First, I query my permissions collection, p_vendors, for an account_id and the vendor_id, both are ObjectID references.
Next, I use async to foreach the returned permission set. When the async call is complete, it returns the prepared data to ExpressJS and its sent off to the client.