Here i am trying to get latest record key p_id value from mongodb collection but i am getting error like :SyntaxError: await is only valid in async function. So how to resolve this issue?
data.controller.js:
module.exports.getData = (req, res, next) => {
var Product = mongoose.model(req.query.collectionname);
const getid = await Product.findOne({ p_id: -1 }).limit(1)
console.log(getid.p_id)
}