How can I use aggregate and find
together in Mongoose?
i.e I have the following schema:
const schema = new Mongoose.Schema({
created: { type:
You can use as the following:
db.locations.aggregate([
{$match:{"your find query"}},
{$project:{"your desired fields"}}
])
In the match you can do stuff like:
{{$match:{name:"whatever"}}
In the project, you can select the fields you want using numbers 0 or 1 like:
{$project:{_id:1,created:0,name:1}}
Which 0 means, do not put and 1 means put.