Registry / database / typeorm-sequence

typeorm-sequence

JSON →
library1.1.3jsnpmunverified

Typeorm-sequence is a lightweight library (v1.1.3) that adds DB sequence support to TypeORM entity columns, currently limited to PostgreSQL. It provides decorators and a base entity to automatically generate next values from named sequences. Development is active but slow, with niche utility for those needing sequence-based IDs instead of auto-increment. The library is minimal, with no external dependencies beyond TypeORM and a PostgreSQL driver. It lacks support for other databases and has not been updated recently.

npm install typeorm-sequence
INSTALL
IMPORT
SIG · TYPEORM-SEQUENCE
T
typeorm-sequence
databasejavascriptv1.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EntityWithSequence
✓ import { EntityWithSequence } from 'typeorm-sequence'
✗ const { EntityWithSequence } = require('typeorm-sequence');
ESM-only; CommonJS require may not work in all environments without transpilation.
NextVal
✓ import { NextVal } from 'typeorm-sequence'
✗ import NextVal from 'typeorm-sequence';
Named export, not default.
Sequence
✓ import { Sequence } from 'typeorm-sequence'
✗ import { Sequence } from 'typeorm';
If exported (not shown in README), it's from the library, not TypeORM.

Shows how to define an entity with a sequence-based primary key using @NextVal decorator and EntityWithSequence base class.

import { Entity, Column, PrimaryColumn } from 'typeorm'; import { NextVal, EntityWithSequence } from 'typeorm-sequence'; @Entity({ name: 'client_table' }) export class Client extends EntityWithSequence { @NextVal('seq_client') @PrimaryColumn({ name: 'client_id' }) id: number; @Column({ name: 'client_name' }) name: string; constructor() { super(); } } async function example() { const connection = await createConnection({ type: 'postgres', host: 'localhost', port: 5432, username: 'user', password: process.env.PG_PASSWORD ?? '', database: 'test', entities: [Client], synchronize: true, }); const repo = connection.getRepository(Client); const client = repo.create({ name: 'Test' }); await repo.save(client); console.log(client.id); // Uses sequence next value }
Debug
Known issues
gotchaOnly works with PostgreSQL. Other databases (MySQL, SQLite) are not supported despite claims of future support.
fix
Use PostgreSQL or consider alternative libraries like 'typeorm-sequencing'.
affects: <=1.1.3
gotchaEntity must extend EntityWithSequence; cannot use plain TypeORM entity class.
fix
Ensure your entity class extends EntityWithSequence from the library.
affects: >=1.0.0
gotchaSequence must exist in the database before usage; library does not create it automatically.
fix
Manually create the sequence (e.g., CREATE SEQUENCE seq_client) or use TypeORM migrations.
affects: >=1.0.0
deprecatedPackage is not actively maintained; last release over 2 years ago.
fix
Consider forking or using a more active alternative.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'typeorm-sequence' or its corresponding type declarations.
Missing install or incorrect import style.
fix
Run 'npm install typeorm-sequence' and ensure import uses named exports: import { NextVal } from 'typeorm-sequence'.
Error: Sequence "seq_client" does not exist.
Database sequence not created before entity save.
fix
Execute 'CREATE SEQUENCE seq_client' in your PostgreSQL database.
TypeError: Class extends value undefined is not a constructor or null
Entity does not correctly extend EntityWithSequence, possibly due to mis-import.
fix
Verify import: import { EntityWithSequence } from 'typeorm-sequence' and ensure class extends it.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
typeormrequiredPeer dependency: required for entity decoration and database interaction.
pgoptionalOptional: PostgreSQL driver needed for database connection.
Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
typeorm-sequence — npm install typeorm-sequence · libregistry