Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Feature Request] nanoid support custom alphabet

Aperta
#2,348 9 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #2377 di @sanny-io — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
sqlite, typescript
Ambito
databases

Direzione di ricerca

The request is to let @default(nanoid(16)) in the ZenStack schema draw from a user-supplied alphabet, configured via a new option on ZenStackClient (shown next to SqliteDialect in the body). Start by locating where the nanoid default is resolved and where client options are declared, then thread a nanoidCustomAlphabet value through to the ID generator so existing nanoid(n) usage keeps working. Done means the schema default honors the configured alphabet and the behaviour is covered by a test; note that a linked pull request (#2377) was closed unmerged and the thread has been silent for months, so confirm the desired API with maintainers before starting.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Most of the time, we need to define a special business ID field for models, such as post_id or user_id. We often choose UUID or nanoid for generating these IDs. However, when using nanoid, we found that it cannot meet our requirements because it defaults to generating IDs with uppercase letters and numbers. Sometimes we prefer IDs in lowercase letters and numbers, which nanoid cannot handle. As a result, we are forced to set the ID field as non‑nullable and generate a compliant ID in the code layer when creating records.

This is not an ideal practice. Providing a custom alphabet feature for nanoid would help reduce this mental overhead. Moreover, I believe the optimal API design would be:

  • Keep the usage as is:
    @default(nanoid(16))

  • Add an optional parameter when creating the client:

export const db = new ZenStackClient(schema, {
    dialect: new SqliteDialect({
        database: new SQLite(':memory:'),
    }),
    nanoidCustomAlphabet: "1234567890abcdef"
});
Lingua principale
TypeScript
Stelle
2.9k
Fork
157
Merge medio
11h 42m
PR unite (30g)
20

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zenstackhq/zenstack

Tutte le issue di zenstackhq/zenstack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.