Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions src/app/Http/ProjectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@ const Project = require('../Models/Project');
const uid = require('uid-safe');

function project(req, res) {
//res.render('project');

}

// Async function to get a project by id
async function getProjectById(id) {
try {
const project = await Project.findById(id);
return project;
} catch (error) {
console.log(error);
}
}

// Async function to get all projects
async function getAllProjects() {
try {
const projects = await Project.find();
return projects;
} catch (error) {
console.log(error);
}
}


function generateProjectId() {
// TODO: Check if the project id is already in the database.
// Generate a random project id.
Expand Down Expand Up @@ -36,4 +57,6 @@ function newProject(projectName, UserID) {
module.exports = {
project,
generateProjectId,
};
getAllProjects,
getProjectById
};
2 changes: 1 addition & 1 deletion src/app/Models/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ projectSchema = new Schema({

const projectModel = mongo.model('projectModel', projectSchema);

module.exports = projectModel;
module.exports = projectModel;