{"id":44081,"library":"typeorm-sequence","title":"TypeORM Sequence","description":"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.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typeorm","sequence","postgres"],"install":[{"cmd":"npm install typeorm-sequence","lang":"bash","label":"npm"},{"cmd":"yarn add typeorm-sequence","lang":"bash","label":"yarn"},{"cmd":"pnpm add typeorm-sequence","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required for entity decoration and database interaction.","package":"typeorm","optional":false},{"reason":"Optional: PostgreSQL driver needed for database connection.","package":"pg","optional":true}],"imports":[{"note":"ESM-only; CommonJS require may not work in all environments without transpilation.","wrong":"const { EntityWithSequence } = require('typeorm-sequence');","symbol":"EntityWithSequence","correct":"import { EntityWithSequence } from 'typeorm-sequence'"},{"note":"Named export, not default.","wrong":"import NextVal from 'typeorm-sequence';","symbol":"NextVal","correct":"import { NextVal } from 'typeorm-sequence'"},{"note":"If exported (not shown in README), it's from the library, not TypeORM.","wrong":"import { Sequence } from 'typeorm';","symbol":"Sequence","correct":"import { Sequence } from 'typeorm-sequence'"}],"quickstart":{"code":"import { Entity, Column, PrimaryColumn } from 'typeorm';\nimport { NextVal, EntityWithSequence } from 'typeorm-sequence';\n\n@Entity({ name: 'client_table' })\nexport class Client extends EntityWithSequence {\n\n  @NextVal('seq_client')\n  @PrimaryColumn({ name: 'client_id' })\n  id: number;\n\n  @Column({ name: 'client_name' })\n  name: string;\n\n  constructor() {\n    super();\n  }\n}\n\nasync function example() {\n  const connection = await createConnection({\n    type: 'postgres',\n    host: 'localhost',\n    port: 5432,\n    username: 'user',\n    password: process.env.PG_PASSWORD ?? '',\n    database: 'test',\n    entities: [Client],\n    synchronize: true,\n  });\n  const repo = connection.getRepository(Client);\n  const client = repo.create({ name: 'Test' });\n  await repo.save(client);\n  console.log(client.id); // Uses sequence next value\n}","lang":"typescript","description":"Shows how to define an entity with a sequence-based primary key using @NextVal decorator and EntityWithSequence base class."},"warnings":[{"fix":"Use PostgreSQL or consider alternative libraries like 'typeorm-sequencing'.","message":"Only works with PostgreSQL. Other databases (MySQL, SQLite) are not supported despite claims of future support.","severity":"gotcha","affected_versions":"<=1.1.3"},{"fix":"Ensure your entity class extends EntityWithSequence from the library.","message":"Entity must extend EntityWithSequence; cannot use plain TypeORM entity class.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Manually create the sequence (e.g., CREATE SEQUENCE seq_client) or use TypeORM migrations.","message":"Sequence must exist in the database before usage; library does not create it automatically.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider forking or using a more active alternative.","message":"Package is not actively maintained; last release over 2 years ago.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'activ':41 'add':12 'auto':57 'auto-incr':56 'automat':32 'base':29,52 'beyond':67 'column':19 'current':20 'databas':78 'db':13 'decor':26 'depend':66 'develop':39 'driver':72 'entiti':18,30 'extern':65 'generat':33 'id':53 'increment':58 'instead':54 'javascript':85 'lack':74 'librari':9,60 'lightweight':8 'limit':21 'minim':62 'name':37 'need':49 'next':34 'nich':45 'postgr':88 'postgresql':23,71 'provid':25 'recent':84 'sequenc':2,5,14,38,51,87 'sequence-bas':50 'slow':43 'support':15,75 'typeorm':1,4,17,68,86 'typeorm-sequ':3 'updat':83 'util':46 'v1.1.3':10 'valu':35","created_at":"2026-06-05T17:02:53.546369+00:00","updated_at":"2026-06-05T17:02:53.546369+00:00","problems":[{"fix":"Run 'npm install typeorm-sequence' and ensure import uses named exports: import { NextVal } from 'typeorm-sequence'.","cause":"Missing install or incorrect import style.","error":"Cannot find module 'typeorm-sequence' or its corresponding type declarations."},{"fix":"Execute 'CREATE SEQUENCE seq_client' in your PostgreSQL database.","cause":"Database sequence not created before entity save.","error":"Error: Sequence \"seq_client\" does not exist."},{"fix":"Verify import: import { EntityWithSequence } from 'typeorm-sequence' and ensure class extends it.","cause":"Entity does not correctly extend EntityWithSequence, possibly due to mis-import.","error":"TypeError: Class extends value undefined is not a constructor or null"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"typeorm-sequence","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}