BETTERZON-76: Adding method descriptions for backend service methods (#40)

This commit is contained in:
Patrick
2021-05-05 23:20:57 +02:00
committed by GitHub
parent e1da64cac3
commit 2f74519da3
6 changed files with 83 additions and 167 deletions
+11 -33
View File
@@ -23,6 +23,9 @@ import {Vendors} from './vendors.interface';
* Service Methods
*/
/**
* Fetches and returns all known vendors
*/
export const findAll = async (): Promise<Vendors> => {
let conn;
let vendorRows = [];
@@ -66,6 +69,10 @@ export const findAll = async (): Promise<Vendors> => {
return vendorRows;
};
/**
* Fetches and returns the vendor with the specified id
* @param id The id of the vendor to fetch
*/
export const find = async (id: number): Promise<Vendor> => {
let conn;
let vendor: any;
@@ -89,6 +96,10 @@ export const find = async (id: number): Promise<Vendor> => {
return vendor;
};
/**
* Fetches and returns all vendors that match the search term
* @param term the term to match
*/
export const findBySearchTerm = async (term: string): Promise<Vendors> => {
let conn;
let vendorRows = [];
@@ -112,36 +123,3 @@ export const findBySearchTerm = async (term: string): Promise<Vendors> => {
return vendorRows;
};
// export const create = async (newItem: Product): Promise<void> => {
// let conn;
// try {
// conn = await pool.getConnection();
// await conn.query("");
//
// } catch (err) {
// throw err;
// } finally {
// if (conn) conn.end();
// }
// };
//
// export const update = async (updatedItem: Product): Promise<void> => {
// if (models.products[updatedItem.product_id]) {
// models.products[updatedItem.product_id] = updatedItem;
// return;
// }
//
// throw new Error("No record found to update");
// };
//
// export const remove = async (id: number): Promise<void> => {
// const record: Product = models.products[id];
//
// if (record) {
// delete models.products[id];
// return;
// }
//
// throw new Error("No record found to delete");
// };