cityssm/parking-ticket-system

View on GitHub
database/parkingDB/deleteParkingBylaw.js

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
import { clearCacheByTableName } from '../../helpers/functions.cache.js';
export default function deleteParkingBylaw(bylawNumber) {
    const database = sqlite(databasePath);
    const info = database
        .prepare(`update ParkingBylaws
        set isActive = 0
        where bylawNumber = ?
        and isActive = 1`)
        .run(bylawNumber);
    database.close();
    clearCacheByTableName('ParkingBylaws');
    return {
        success: info.changes > 0
    };
}