cityssm/parking-ticket-system

View on GitHub
database/parkingDB/getNextParkingTicketRemarkIndex.js

Summary

Maintainability
A
35 mins
Test Coverage
A
100%
export default function getNextParkingTicketRemarkIndex(ticketId, database) {
    return (database
        .prepare(`select ifnull(max(remarkIndex), 0) as remarkIndexMax
          from ParkingTicketRemarks
          where ticketId = ?`)
        .pluck()
        .get(ticketId) + 1);
}