cityssm/parking-ticket-system

View on GitHub
database/parkingDB/unlockConvictionBatch.js

Summary

Maintainability
A
0 mins
Test Coverage
F
16%
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
export default function unlockConvictionBatch(batchId, sessionUser) {
    const database = sqlite(databasePath);
    const rightNowMillis = Date.now();
    const info = database
        .prepare(`update ParkingTicketConvictionBatches
        set lockDate = null,
        recordUpdate_userName = ?,
        recordUpdate_timeMillis = ?
        where recordDelete_timeMillis is null
        and batchId = ?
        and lockDate is not null
        and sentDate is null`)
        .run(sessionUser.userName, rightNowMillis, batchId);
    database.close();
    return info.changes > 0;
}