cityssm/lottery-licence-manager

View on GitHub
helpers/licencesDB/getMaxOrganizationReminderIndex.ts

Summary

Maintainability
A
3 hrs
Test Coverage
import type * as sqlite from "better-sqlite3";


export const getMaxOrganizationReminderIndexWithDB = (database: sqlite.Database, organizationID: number | string): number => {

  const result: {
    reminderIndex: number;
  } = database.prepare("select reminderIndex" +
    " from OrganizationReminders" +
    " where organizationID = ?" +
    " order by reminderIndex desc" +
    " limit 1")
    .get(organizationID);

  return (result
    ? result.reminderIndex
    : -1);
};