0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

Add aggregate query to HB model

This commit is contained in:
G.Ambatte
2024-04-21 14:35:51 +12:00
parent 98d032913b
commit eb719e34a8

View File

@@ -60,6 +60,12 @@ HomebrewSchema.statics.getByUser = async function(username, allowAccess=false, f
return brews;
};
HomebrewSchema.statics.getAggregate = async function(aggregate, options={}){
const output = await Homebrew.aggregate(aggregate, options)
.catch((error)=>{throw 'Can not get aggregate';});
return output;
};
const Homebrew = mongoose.model('Homebrew', HomebrewSchema);
module.exports = {