Skip to main content

SQBAdapter

SQB is a SQL query builder and ORM for Node.js. @opra/sqb integrates it with the OPRA framework, providing service classes that map OPRA operations to SQB repository calls and handle filter translation, codec decoding, lifecycle hooks, and transaction management.

SQBAdapter is a namespace that provides utility types and functions for this integration.

import { SQBAdapter } from '@opra/sqb';

Functions

prepareFilter

SQBAdapter.prepareFilter(filters: FilterInput | FilterInput[]): any

Converts an OPRA FilterInput (or array of inputs) into an SQB filter expression.


parseRequest

SQBAdapter.parseRequest(context: ExecutionContext): Promise<SQBAdapter.TransformedRequest>

Parses an ExecutionContext and transforms it into an SQB-compatible request object. Supports Entity.Create, Entity.Get, Entity.FindMany, Entity.Update, Entity.UpdateMany, Entity.Delete, Entity.DeleteMany, and Entity.Replace operations.

Throws: TypeError if the context transport is not 'http', or Error if the operation is not supported.


Interfaces

SQBAdapter.TransformedRequest

PropertyTypeDescription
method'create' | 'delete' | 'deleteMany' | 'get' | 'replace' | 'findMany' | 'update' | 'updateMany'The resolved operation method
keyanyThe document identifier, if applicable
dataanyThe input payload, if applicable
optionsanyThe operation options

Types

SQBAdapter.Id

type Id = string | number | boolean | Date;

A single identifier value.


SQBAdapter.IdOrIds

type IdOrIds = Id | Record<string, Id>;

A single identifier or a composite key represented as a plain object.


SQBAdapter.FilterInput

type FilterInput =
| OpraFilter.Expression
| Repository.FindManyOptions['filter']
| string
| undefined;

Accepted input forms for a filter expression. Can be:

  • An operator expression built with SQB operator functions (Eq, And, In, etc. from @sqb/builder)
  • A plain object with optional operator suffixes ({ status: 'active' }, { 'age >': 18 })
  • An OPRA filter string ("status='active' and age>18")
  • undefined (no filter)