我有一个3层的'像MongooseJS这样的关系,它是子文档之间的两个一对多关系。像这样:
var BroadcastSchema = new Schema({
...
_donationAddresses: [{
type: Schema.Types.ObjectId,
ref: 'DonationAddress'
}]
});
var DonationAddressSchema = new Schema({
...
_donations: [{
type: Schema.Types.ObjectId,
ref: 'Donation'
}]
});
var DonationSchema = new Schema({
...
amount: Number
});
我想获得$sum
amount:Number
的{{1}}总数
到目前为止,我已经使用了一个解决方法here来填充DonationSchema
(因为据我所知,你可以填充一个填充} em> so far as I know)
Donation