cityssm/parking-ticket-system

View on GitHub
database/parkingDB/deleteParkingTicketRemark.js

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
export default function deleteParkingTicketRemark(ticketId, remarkIndex, sessionUser) {
    const database = sqlite(databasePath);
    const info = database
        .prepare(`update ParkingTicketRemarks
        set recordDelete_userName = ?,
        recordDelete_timeMillis = ?
        where ticketId = ?
        and remarkIndex = ?
        and recordDelete_timeMillis is null`)
        .run(sessionUser.userName, Date.now(), ticketId, remarkIndex);
    database.close();
    return {
        success: info.changes > 0
    };
}