cityssm/parking-ticket-system

View on GitHub
database/parkingDB/deleteParkingOffence.js

Summary

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