MCPcopy Create free account
hub / github.com/TomDoesTech/REST-API-Tutorial-Updated / findProduct

Function findProduct

src/service/product.service.ts:24–42  ·  view source on GitHub ↗
(
  query: FilterQuery<ProductDocument>,
  options: QueryOptions = { lean: true }
)

Source from the content-addressed store, hash-verified

22}
23
24export async function findProduct(
25 query: FilterQuery<ProductDocument>,
26 options: QueryOptions = { lean: true }
27) {
28 const metricsLabels = {
29 operation: "findProduct",
30 };
31
32 const timer = databaseResponseTimeHistogram.startTimer();
33 try {
34 const result = await ProductModel.findOne(query, {}, options);
35 timer({ ...metricsLabels, success: "true" });
36 return result;
37 } catch (e) {
38 timer({ ...metricsLabels, success: "false" });
39
40 throw e;
41 }
42}
43
44export async function findAndUpdateProduct(
45 query: FilterQuery<ProductDocument>,

Callers 3

updateProductHandlerFunction · 0.90
getProductHandlerFunction · 0.90
deleteProductHandlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected