Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bdc8d9a8e0 |
No files matched your search
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "multi-stub",
|
"name": "multi-stub",
|
||||||
"version": "1.1.2",
|
"version": "1.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
const router = require('express').Router()
|
const router = require('express').Router()
|
||||||
const {MasterModel} = require('./model/master')
|
const {MasterModel} = require('./model/master')
|
||||||
const mongoose = require("mongoose")
|
const mongoose = require("mongoose")
|
||||||
|
const {OrderModel} = require("./model/order")
|
||||||
|
|
||||||
|
|
||||||
router.get('/masters', async (req, res,next) => {
|
router.get("/masters", async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const master = await MasterModel.find({})
|
const masters = await MasterModel.find({});
|
||||||
res.status(200).send({success: true, body: master})
|
const orders = await OrderModel.find({});
|
||||||
|
|
||||||
|
const mastersWithOrders = masters.map((master) => {
|
||||||
|
const masterOrders = orders.filter((order) => {
|
||||||
|
return (
|
||||||
|
order?.master && order.master.toString() === master._id.toString()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const schedule = masterOrders.map((order) => ({
|
||||||
|
id: order._id,
|
||||||
|
startWashTime: order.startWashTime,
|
||||||
|
endWashTime: order.endWashTime,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: master._id,
|
||||||
|
name: master.name,
|
||||||
|
schedule: schedule,
|
||||||
|
phone: master.phone,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200).send({ success: true, body: mastersWithOrders });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error)
|
next(error);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
router.delete('/masters/:id', async (req, res,next) => {
|
router.delete('/masters/:id', async (req, res,next) => {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 294 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user