Installation
KnexService
The main service class for SQL operations via Knex.Constructor
KnexAdapterOptions
required
Configuration options for the Knex adapter
Knex
required
The Knex instance
string
required
The table name
string
default:"id"
Name of the id field property
string
Database schema name (for PostgreSQL, MSSQL)
PaginationParams
Pagination settings with
default and max page sizeboolean | string[]
Allow multiple updates. Can be
true, false, or an array of method namesRecord<string, string>
Custom query operators mapping. Example:
{ '$regexp': '~*' }Service Methods
find
Retrieve multiple records from the table.KnexAdapterParams
Paginated<Result> | Result[]
Paginated results or array depending on settings
get
Retrieve a single record by id.Id
required
The record id to retrieve
Result
The found record
create
Create one or more new records.Data | Data[]
required
Record data to create. Arrays are processed sequentially
Result | Result[]
The created record(s)
update
Completely replace a record.Id
required
The record id to update
Data
required
Complete record data. Fields not provided will be set to null
Result
The updated record
patch
Partially update one or multiple records.Id | null
required
The record id to patch, or
null to patch multiple records matching the queryPatchData
required
Partial data to merge with existing record(s)
Result | Result[]
The patched record(s)
remove
Remove one or multiple records.Id | null
required
The record id to remove, or
null to remove multipleResult | Result[]
The removed record(s)
KnexAdapter
The base adapter class thatKnexService extends.
Properties
Model
Access the Knex instance.fullName
Get the full table name including schema.Methods
db
Get a Knex query builder for the table, with transaction support.KnexAdapterParams
Parameters with optional transaction
Knex.QueryBuilder
Query builder for the configured table
createQuery
Create a Knex query from Feathers parameters.Knex.QueryBuilder
Configured query builder with all filters applied
knexify
Convert a Feathers query object to Knex where clauses.Knex.QueryBuilder
required
The Knex query builder to modify
Query
required
Feathers query object