Created the patchProject method in the projects.ts controller
This commit is contained in:
parent
23c3a91956
commit
4eaf23fd78
@ -19,4 +19,18 @@ export const deleteProject = async (id: string) => {
|
||||
// TODO: Delete all licenses, groups, permissions, ..
|
||||
|
||||
await project.delete();
|
||||
};
|
||||
|
||||
export const patchProject = async (id: string, config: {
|
||||
name: string, defaults: { licenseKey: string, groups: [], permissions: [], expirationDate: Date }
|
||||
}) => {
|
||||
if (!Types.ObjectId.isValid(id))
|
||||
return { code: 3, message: "Invalid object id provided" };
|
||||
|
||||
const project = await Project.findById(id);
|
||||
if (project === null) return { code: 5009, message: "The provided project id does not exist" };
|
||||
|
||||
// TODO: Check if groups & permissions exist
|
||||
|
||||
await project.updateOne({ name: config.name, defaults: Object.assign(project.defaults, config.defaults) });
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user