cityssm/parking-ticket-system

View on GitHub
database/parkingDB/updateParkingOffencesByBylawNumber.js

Summary

Maintainability
A
0 mins
Test Coverage
F
17%
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
export default function updateParkingOffencesByBylawNumber(requestBody) {
    const database = sqlite(databasePath);
    const info = database
        .prepare(`update ParkingOffences
        set offenceAmount = ?,
        discountOffenceAmount = ?,
        discountDays = ?
        where bylawNumber = ?
        and isActive = 1`)
        .run(requestBody.offenceAmount, requestBody.discountOffenceAmount, requestBody.discountDays, requestBody.bylawNumber);
    database.close();
    return {
        success: info.changes > 0
    };
}