I'm trying to use .aggregate() with other mongo shell methods and i got UnhandledPromiseRejectionWarning: TypeError: User.find(...).select(...).sort(...).aggregate is not a function
const users = await User
.find(findParams)
.select(userResponse)
.sort(sortParams)
.aggregate(([
{
$project:{
dateCreated: {$dateToString: {format: "%G-%m-%d %H:%M:%S", date: "$dateCreated"}},
}
}
]))
.exec()
BUT, when i use .aggregate() without other methods it works perfect.
const users = await User
.aggregate(([
{
$project:{
dateCreated: {$dateToString: {format: "%G-%m-%d %H:%M:%S", date: "$dateCreated"}},
}
}
]))
.exec()
Can i insert it with other methods but without getting this error. Thanks