MongoDB: how to get the all the embedded data? I have this data:

&gt; db.Category.find().pretty()
{
    "_id" : ObjectId("542450a928db034349fb3bf2"),
    "name" : "A category",
    "products" : [
        {
            "_id" : ObjectId("542450a928db034349fb3bf3"),
            "name" : "Producto de categoria",
            "price" : 11.11
        }
    ]
}


When I run db.Category.find( {}, {products:1} ) I get this:

{ "_id" : ObjectId("542450a928db034349fb3bf2"), "products" : [ { "_id" : ObjectId("542450a928db034349fb3bf3"), "name" : "Producto de categoria", "price" : 11.11 } ] }


I get the data about one product, but how can I get the data about all products?
If you had multiple documents containing products, you could retrieve all as follows by capturing the query cursor and iterating over the set:

replset:PRIMARY&gt; var cur = db.Category.find( {}, {products:1} );
replset:PRIMARY&gt; while (cur.hasNext()) {
... var doc = cur.next();
... printjson(doc);
... }
{
    "_id" : ObjectId("542450a928db034349fb3bf2"),
    "products" : [
        {
            "_id" : ObjectId("542450a928db034349fb3bf3"),
            "name" : "Producto de categoria",
            "price" : 11.11
        }
    ]
}


If you have multiple products within the "products" array then you would iterate over the array contained in each result document.