Version: 0.16.x

KnexDBDataProvider

Knex.js database data provider exposing basic CRUD operations that works with all databases that knex supports. Layer is tested with following databases:

  • SQLite (by SQLiteKnexDBDataProvider)
  • MySQL (MariaDB)
  • Postgres

NOTE: For SQLite use dedicated SQLiteKnexDBDataProvider that implements more speficic creation method to avoid the not supported returning() statement.

Type parameters

Type

Hierarchy

Implements

  • GraphbackDataProvider‹Type›

Index

Constructors

Properties

Methods

Constructors

constructor

+ new KnexDBDataProvider(model: ModelDefinition, db: Knex): KnexDBDataProvider

Defined in KnexDBDataProvider.ts:20

Parameters:

NameType
modelModelDefinition
dbKnex

Returns: KnexDBDataProvider

Properties

Protected db

db: Knex

Defined in KnexDBDataProvider.ts:18


Protected tableMap

tableMap: ModelTableMap

Defined in KnexDBDataProvider.ts:20


Protected tableName

tableName: string

Defined in KnexDBDataProvider.ts:19

Methods

batchRead

batchRead(relationField: string, ids: string[], filter?: QueryFilter, selectedFields?: string[]): Promise‹Type[][]›

Defined in KnexDBDataProvider.ts:100

Parameters:

NameType
relationFieldstring
idsstring[]
filter?QueryFilter
selectedFields?string[]

Returns: Promise‹Type[][]›


count

count(filter?: QueryFilter): Promise‹number›

Defined in KnexDBDataProvider.ts:93

Parameters:

NameType
filter?QueryFilter

Returns: Promise‹number›


create

create(data: Type, selectedFields?: string[]): Promise‹Type›

Defined in KnexDBDataProvider.ts:28

Parameters:

NameType
dataType
selectedFields?string[]

Returns: Promise‹Type›


delete

delete(data: Partial‹Type›, selectedFields?: string[]): Promise‹Type›

Defined in KnexDBDataProvider.ts:53

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


findBy

findBy(args?: FindByArgs, selectedFields?: string[]): Promise‹Type[]›

Defined in KnexDBDataProvider.ts:77

Parameters:

NameType
args?FindByArgs
selectedFields?string[]

Returns: Promise‹Type[]›


findOne

findOne(args: Partial‹Type›, selectedFields?: string[]): Promise‹Type›

Defined in KnexDBDataProvider.ts:66

Parameters:

NameType
argsPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


Protected getSelectedFields

getSelectedFields(selectedFields: string[]): string[] | ""*

Defined in KnexDBDataProvider.ts:114

Parameters:

NameType
selectedFieldsstring[]

Returns: string[] | ""*


update

update(data: Partial‹Type›, selectedFields?: string[]): Promise‹Type›

Defined in KnexDBDataProvider.ts:38

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


Private usePage

usePage(query: QueryBuilder, page?: GraphbackPage): QueryBuilder‹any, any›

Defined in KnexDBDataProvider.ts:118

Parameters:

NameType
queryQueryBuilder
page?GraphbackPage

Returns: QueryBuilder‹any, any›