import db from './../database.js';

export default function getContainers(req, res) {
  const id = req.cookies.containerProject;

  db.find('containers', {
    userAccess: id,
    name: {
      $exists: true  // Getting all containers that have already been configured
    }
  }, {
    data: 0,
    dates: 0
  })
  .then((containers) => {
    if (containers) {
      res.send({containers: containers});
    } else {
      res.send({containers: []});
    }
  })
  .catch((e) => {
    console.log('Containers were not received:', e.message);
    res.status(401);
    res.send(e.message);
  });
}
