Skip to content
View mnevfel's full-sized avatar
🎯
Focusing
🎯
Focusing

Organizations

@ceobeedotdev @mobixify @wisylink

Block or report mnevfel

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Content in all repositories owned by your account will be closed.
Maximum 250 characters. Please don’t include any personal information such as legal names or email addresses. This note will only be visible to you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
mnevfel/README.md
mnevfel

Mustafa Nevfel

I'm a software architect and founder in Izmir, Türkiye. I run Mobixify, an independent software studio, and write engineering notes with code.

I have worked on production software since 2013, across the full stack: backend, frontend, mobile, AWS and real-time systems.

Notes

Newest first. Each note carries working code.

Shorter code references are at mnevfel.com/snippets. All notes are at mnevfel.com/notes.

From Gapless invoice numbering in PostgreSQL without a sequence. The row lock orders issuers, and a rollback gives the number back.

-- per issue, READ COMMITTED (the default)
BEGIN;
UPDATE number_counters SET last_seq = last_seq + 1
WHERE tenant_id = $1 AND series = $2
RETURNING last_seq;          -- zero rows: no such series, ROLLBACK
INSERT INTO documents (id, tenant_id, series, seq_no, idempotency_key)
VALUES ($3, $1, $2, $4, $5); -- $4 is the last_seq returned above
COMMIT;                      -- on any error, including 23505: ROLLBACK

Open source

  • 2026-11-13 pg-gapless: Gapless invoice and receipt numbers in PostgreSQL for Node.js, safe under retries and rollbacks

Work

Most of my work was for employers and clients, so it is not public.

mnevfel.com · Now · LinkedIn · X

Pinned Loading

  1. pg-gapless pg-gapless Public

    Gapless invoice and receipt numbers in PostgreSQL for Node.js, safe under retries and rollbacks

    JavaScript