how to return the result of two mongoDB queries in a single array


I am using mongoDB and Codeigniter PHP framework in my project. i am dealing with an E-commerce website. i am using mongoDB to store product features and images of the products. product details are stored in a collection and their images are stored in GridFS bucket with the product code. i want to return a product details and images by passing the product code to DB. i wrote two queries, one for retrieving the product details from the collection one for the images of the product from the GridFS.

The two query results are allocated to two iam not able to combine the result and make it as a single araay to pass that into my view page.

I am bugged up with this. please help..


I dont have experience in php, but imho, this question mixes apples with bananas.

GridFs storage is using a bit different serialisation as it can cover documents over 16MB limit (the chunk size is about 255kB) and that is reflected in driver interface. Mongo single document can be up to 16MB, so as far as images after serialisation are fitting in BSON limit, then using standard collection will could act as a solution.

This video can help you solving your question :)
By: admin