Skip to content

Commit

Permalink
fix use of "new Date()" in pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
paolini committed Nov 8, 2023
1 parent 7fe45bf commit 7ccb255
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dm-manager",
"version": "1.3.9",
"version": "1.3.10",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.2",
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/RoomController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class RoomController extends Controller {
this.queryPipeline.push(
// inserisce startDate e endDate con la data odierna
{$addFields: {
startDate: new Date(),
endDate: new Date(),
startDate: "$$NOW",
endDate: "$$NOW",
}},
...RoomAssignment.roomRoomAssignmentPipeline()
)
Expand Down
9 changes: 7 additions & 2 deletions server/controllers/public/seminars.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ const EventSeminar = require('../../models/EventSeminar')
async function seminarsQuery(req) {
const pipeline = [
{ $match: {
startDatetime: {$gte: new Date()}
$expr: {
$gte: [
"$startDatetime",
"$$NOW"],
}
}},
{ $lookup: {
from: 'people',
Expand Down Expand Up @@ -70,7 +74,8 @@ async function seminarsQuery(req) {
}}
]

// console.log(JSON.stringify({pipeline}))

console.log(JSON.stringify({pipeline}))

const seminars = await EventSeminar.aggregate(pipeline)

Expand Down

0 comments on commit 7ccb255

Please sign in to comment.