When fetching MongoDB data, I encountered an issue. Using the JavaScript parameter to retrieve data from MongoDB resulted in a null return, but manually typing it brought all the data without any problems. That part is working fine.
const data = await NumbersModel.aggregate([{
$project: {
Datas: {
$filter: {
input: "$Datas",
as: "data",
cond: {
$gte: ["$$data.time", 0]
}
}
}
}
}])
res.send(data)
However, this section is not functioning correctly.
if (req.query.lasttimestamp === null) return res.send(`cannot be empty`)
let lasttimestamp = req.query.lasttimestamp
const data = await NumbersModel.aggregate([
{
$project: {
Datas: {
$filter: {
input: "$Datas",
as: "data",
cond: { $gte: [ "$$data.time", lasttimestamp ] }
}
}
}
}
])
res.send(data)