Skip to main content

SQL

@opra/sqb integrates SQB — a SQL query builder and ORM for Node.js — with the OPRA framework. It provides two service base classes that handle codec generation, filter translation, projection, pagination, lifecycle hooks, and the for(context) per-request wiring, leaving your code focused on business logic.

npm install @opra/sqb @sqb/connect @sqb/builder

You also need a dialect adapter, for example:

npm install @sqb/postgres

Which service should I use?

Your data shapeUse
A table (or view) with multiple rows, each identified by a keySqbCollectionService
A table that always holds exactly one rowSqbSingletonService

Both share the same configuration, the same for(context) pattern, and the same lifecycle hook interface.


Service hierarchy

SqbServiceBase shared base: db connection, withTransaction
└── SqbEntityService CRUD primitives + lifecycle hooks + interceptor
├── SqbCollectionService full CRUD on a table or view
└── SqbSingletonService single-row operations (no key argument)

Guides