{"size": 1090, "ext": "js", "max_stars_repo_path": "routers/api/maintenance-services.js", "max_stars_repo_name": "virendrapatel62/bl", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routers/api/maintenance-services.js", "max_issues_repo_name": "virendrapatel62/bl", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routers/api/maintenance-services.js", "max_forks_repo_name": "virendrapatel62/bl", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.2777777778, "max_line_length": 91, "alphanum_fraction": 0.6256880734}
const Router = require('express').Router()

const {MaintenanceSubServices}  = require('../../models/maintenance-sub-services');
const {CoreServices}  = require('../../models/coreservices');
const {SubServices}  = require('../../models/subservices');

Router.get('/' , async(req , res)=>{
    const services = await MaintenanceSubServices.find().populate('coreService').select();
    // const a = JSON.stringify(services)
    res.send(services)    
})

Router.get('/core' , async(req , res)=>{
    const services = await CoreServices.find().populate().select();
    // const a = JSON.stringify(services)
    res.send(services)    
})
Router.get('/core/:id' , async(req , res)=>{
    const services = await CoreServices.findOne({_id : req.params.id}).populate().select();
    const sub = await SubServices.find({
        _id : {
            $in :services.subservices
        }
    }).select();
    var x = {};
    x.name = services.name;
    x._id = services._id.toString();
    x.subservices = sub
    // const a = JSON.stringify(services)
    res.send(x)    
})


module.exports = Router;

