24 lines
514 B
TypeScript
24 lines
514 B
TypeScript
import { acquireConnection } from './pool.js'
|
|
|
|
export default async function getNextContractId(
|
|
contractId: number | string
|
|
): Promise<number | undefined> {
|
|
const database = await acquireConnection()
|
|
|
|
const result = database
|
|
.prepare(
|
|
`select contractId
|
|
from Contracts
|
|
where recordDelete_timeMillis is null
|
|
and contractId > ?
|
|
order by contractId
|
|
limit 1`
|
|
)
|
|
.pluck()
|
|
.get(contractId) as number | undefined
|
|
|
|
database.release()
|
|
|
|
return result
|
|
}
|