We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the controller/jobs.js -> showStats When I try this code from the course it is not working for the new Mongoose version "mongoose": "^8.5.2":
const showStats = async (req, res) => { let stats = await Job.aggregate([ { $match: { createdBy: new mongoose.Types.ObjectId(req.user.userId) } }, { $group: { _id: '$status', count: { $sum: 1 } } }, ]) console.log(stats) res.status(StatusCodes.OK).json({ defaultStats: {}, monthlyApplications: [] }) }
This is the issue from my console:
When you try the suggestion using the new it will work but there will be some deprecation warnings:
new
To solve the issue what I did is to use the string interpolation to make sure that I am passing a string.
Of course, if you're not using the new version of Node and Mongoose, this might not work for you.
The text was updated successfully, but these errors were encountered:
For the latest mongoose, please use mongoose.Types.ObjectId.createFromHexString(req.user.userId)!
mongoose.Types.ObjectId.createFromHexString(req.user.userId)
Sorry, something went wrong.
Yeah, this is another alternative, this might also work. However, using string interpolation worked for me.
No branches or pull requests
In the controller/jobs.js -> showStats
When I try this code from the course it is not working for the new Mongoose version "mongoose": "^8.5.2":
This is the issue from my console:
When you try the suggestion using the
new
it will work but there will be some deprecation warnings:To solve the issue what I did is to use the string interpolation to make sure that I am passing a string.
Of course, if you're not using the new version of Node and Mongoose, this might not work for you.
The text was updated successfully, but these errors were encountered: