condition check lambda
This commit is contained in:
22
lambdas/conditionCheckReminder/queries.js
Normal file
22
lambdas/conditionCheckReminder/queries.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const { query } = require("../shared/db/connection");
|
||||
|
||||
/**
|
||||
* Check if a condition check already exists for a rental and check type.
|
||||
* @param {string} rentalId - UUID of the rental
|
||||
* @param {string} checkType - Type of check (pre_rental_owner, rental_start_renter, etc.)
|
||||
* @returns {Promise<boolean>} True if a condition check exists
|
||||
*/
|
||||
async function conditionCheckExists(rentalId, checkType) {
|
||||
const result = await query(
|
||||
`SELECT id FROM "ConditionChecks"
|
||||
WHERE "rentalId" = $1 AND "checkType" = $2
|
||||
LIMIT 1`,
|
||||
[rentalId, checkType]
|
||||
);
|
||||
|
||||
return result.rows.length > 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
conditionCheckExists,
|
||||
};
|
||||
Reference in New Issue
Block a user