1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-09 23:40:06 +00:00

fix: use custom logic for handling sequence ids

This commit is contained in:
2023-05-01 19:28:51 +05:00
parent d2f011e8a9
commit dba53de646
9 changed files with 76 additions and 93 deletions

View File

@@ -0,0 +1,15 @@
import Counter from '../model/Counter'
export const getSequenceNextValue = async (seqName: string) => {
const seqDoc = await Counter.findOne({ id: seqName })
if (!seqDoc) {
await Counter.create({ id: seqName, seq: 1 })
return 1
}
seqDoc.seq += 1
await seqDoc.save()
return seqDoc.seq
}