database/parkingDB/markLookupBatchAsSent.js
import { dateToInteger } from '@cityssm/utils-datetime';
import sqlite from 'better-sqlite3';
import { parkingDB as databasePath } from '../../data/databasePaths.js';
export default function markLookupBatchAsSent(batchId, sessionUser) {
const database = sqlite(databasePath);
const rightNow = new Date();
const info = database
.prepare(`update LicencePlateLookupBatches
set sentDate = ?,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where batchId = ?
and recordDelete_timeMillis is null
and lockDate is not null
and sentDate is null`)
.run(dateToInteger(rightNow), sessionUser.userName, rightNow.getTime(), batchId);
database.close();
return info.changes > 0;
}