Skip to content

Commit

Permalink
template controller; #8, #19, #11
Browse files Browse the repository at this point in the history
  • Loading branch information
j-000 committed Jul 29, 2023
1 parent 6ff66fd commit f162a24
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions database/services/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const { TemplateModel } = require("../../models/template");


async function create(orgid, filepath, name, type) {
try {
const result = await TemplateModel.create({ orgid, filepath, name, type});
return result;
} catch (error) {
throw error;
}
}

async function getOne(obj, proj) {
try {
const result = await TemplateModel.findOne(obj, proj).exec();
return result
} catch (error) {
throw error
}
}

async function getMany(obj, proj) {
try {
const result = await TemplateModel.find(obj, proj).exec();
return result
} catch (error) {
throw error
}
}

async function remove(obj) {
try {
const result = await TemplateModel.findByIdAndDelete(obj).exec();
return result
} catch (error) {
throw error
}
}


module.exports = {
create,
getMany,
getOne,
remove
}

0 comments on commit f162a24

Please sign in to comment.