(
query: FilterQuery<ProductDocument>,
options: QueryOptions = { lean: true }
)
| 22 | } |
| 23 | |
| 24 | export 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 | |
| 44 | export async function findAndUpdateProduct( |
| 45 | query: FilterQuery<ProductDocument>, |
no outgoing calls
no test coverage detected