I'm bulding an app using Node/Express/MongoDB/Mongoskin.
I the database I have a collection namned "clients", where documents containing information about client account. Each client document contains an array that contains invoice-objects, like this:
doc.invoices = [
{year: 2012,
quarter: 1,
daily: 912.00,
sms: 42.00,
paid: true},
{year: 2012,
quarter: 2,
daily: 913.00,
sms: 55.00,
paid: true},
{year: 2012,
quarter: 3,
daily: 876.00,
sms: 82.00,
paid: true},
{year: 2012,
quarter: 4,
daily: 903.00,
sms: 93.00,
paid: false},
{year: 2013,
quarter: 1,
daily: 915.00,
sms: 67.00,
paid: true},
{year: 2013,
quarter: 2,
daily: 920.00,
sms: 35.00,
paid: true},
{year: 2013,
quarter: 3,
daily: 880.00,
sms: 92.00,
paid: true},
{year: 2013,
quarter: 4,
daily: 900.00,
sms: 85.00,
paid: false}
]
Question: Lets say i want to query ALL documents from this collection, like in a Superadmin-view showing all clients, but i want to limit the information returned from the invoice-array to objects where "year" is equal to a certain value, for example 2013, current year.
I guess projections is what I need, but the problem is that the projection is only returning the first result it finds...