Filtereing mongodb data based on brithday and anniversary timestamp

PHOTO EMBED

Thu Jun 10 2021 11:50:43 GMT+0000 (Coordinated Universal Time)

Saved by @tapasdash #nodejs #mongoose #mongodb #aggregate

const dateFilter = asyncHandler(async (req, res) => {
  const month = 6;
  const day = 10;
  const feedbacks = await Feedback.find({
    $expr: {
      $or: [
        {
          $eq: [{ $month: "$birthday" }, month],
          $eq: [{ $dayOfMonth: "$birthday" }, day],
        },
        {
          $eq: [{ $month: "$anniversary" }, month],
          $eq: [{ $dayOfMonth: "$anniversary" }, day],
        },
      ],
    },
  });
  console.log({ feedbacks });
});
content_copyCOPY