Compare commits

...

8 Commits

Author SHA1 Message Date
Primakov Alexandr Alexandrovich
8a2afc3f1b 1.1.1 2025-01-19 21:05:16 +03:00
Primakov Alexandr Alexandrovich
d824844ae5 populate author of comments 2025-01-19 21:05:08 +03:00
Primakov Alexandr Alexandrovich
f95a26acbb todo-app: get item by id 2025-01-19 20:44:26 +03:00
e0618e431f feat: add get date orders 2025-01-19 11:29:11 +03:00
1b93a8e2bb fix: change get for orders v2 2025-01-19 10:23:48 +03:00
b8dc15cbc6 Merge pull request 'feat: use stubs for orders data (#64)' (#62) from feature/dry-wash-orders into master
Reviewed-on: #62
Reviewed-by: Primakov Alexandr Alexandrovich <primakovpro@gmail.com>
2025-01-19 10:11:41 +03:00
RustamRu
949416d2a3 feat: use stubs for orders data (#64) 2025-01-18 23:02:45 +03:00
RustamRu
1ec9f1a7ec Revert "feat: use stubs for orders data (#64)"
This reverts commit 87c1cbb19e.
2025-01-18 23:00:20 +03:00
4 changed files with 20 additions and 12 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"dependencies": {
"axios": "^1.7.9",

View File

@@ -1,6 +1,6 @@
{
"name": "multi-stub",
"version": "1.1.0",
"version": "1.1.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@@ -1,13 +1,21 @@
const router = require('express').Router()
const { OrderModel } = require('./model/order')
router.get('/orders', async (req, res, next) => {
try {
const orders = await OrderModel.find({})
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 })
} catch (error) {
next(error)
}
})
module.exports = router
module.exports = router

View File

@@ -42,12 +42,12 @@ router.get('/:todoId/:itemId', async (req, res) => {
return res.send(getAnswer(new Error('no such todo')))
}
const item = await ItemModel.findById(itemId).populate('comments').exec()
const item = await ItemModel.findById(itemId).populate({ path: 'comments', populate: { path: 'author' } }).exec()
if (!item) {
return res.send(getAnswer(new Error('no such item')))
}
res.send(getAnswer(null, item.comments))
res.send(getAnswer(null, item))
})
module.exports = router