multy-stub/server/routers/dry-wash/arm-orders.js
2025-01-19 11:29:11 +03:00

22 lines
691 B
JavaScript

const router = require('express').Router()
const { OrderModel } = require('./model/order')
router.post('/orders', async (req, res, next) => {
const {startDate, endDate} = req.body
if (!startDate || !endDate) {
throw new Error('startDate and endDate are required')
}
const orders = await OrderModel.find({
$or: [
{startWashTime: { $gte: new Date(startDate), $lte: new Date(endDate) }},
{endWashTime: { $gte: new Date(startDate), $lte: new Date(endDate) }},
]
})
res.status(200).send({ success: true, body: orders })
})
module.exports = router