Version: 0.15.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(baseType: GraphQLObjectType, db: Knex): KnexDBDataProvider

Defined in KnexDBDataProvider.ts:22

Parameters:

NameType
baseTypeGraphQLObjectType
dbKnex

Returns: KnexDBDataProvider

Properties#

Protected baseType#

baseType: GraphQLObjectType

Defined in KnexDBDataProvider.ts:20


Protected db#

db: Knex

Defined in KnexDBDataProvider.ts:19


Protected tableMap#

tableMap: ModelTableMap

Defined in KnexDBDataProvider.ts:22


Protected tableName#

tableName: string

Defined in KnexDBDataProvider.ts:21

Methods#

batchRead#

batchRead(relationField: string, ids: string[], filter: any, context: GraphbackContext): Promise‹Type[][]›

Defined in KnexDBDataProvider.ts:104

Parameters:

NameType
relationFieldstring
idsstring[]
filterany
contextGraphbackContext

Returns: Promise‹Type[][]›


count#

count(filter: any): Promise‹number›

Defined in KnexDBDataProvider.ts:97

Parameters:

NameType
filterany

Returns: Promise‹number›


create#

create(data: Type, context: GraphbackContext): Promise‹Type›

Defined in KnexDBDataProvider.ts:31

Parameters:

NameType
dataType
contextGraphbackContext

Returns: Promise‹Type›


delete#

delete(data: Type, context: GraphbackContext): Promise‹Type›

Defined in KnexDBDataProvider.ts:57

Parameters:

NameType
dataType
contextGraphbackContext

Returns: Promise‹Type›


findBy#

findBy(filter: QueryFilter‹Type›, context: GraphbackContext, page?: GraphbackPage, orderBy?: GraphbackOrderBy): Promise‹Type[]›

Defined in KnexDBDataProvider.ts:81

Parameters:

NameType
filterQueryFilter‹Type›
contextGraphbackContext
page?GraphbackPage
orderBy?GraphbackOrderBy

Returns: Promise‹Type[]›


findOne#

findOne(args: Partial‹Type›, context: GraphbackContext): Promise‹Type›

Defined in KnexDBDataProvider.ts:70

Parameters:

NameType
argsPartial‹Type›
contextGraphbackContext

Returns: Promise‹Type›


Protected getSelectedFields#

getSelectedFields(context: GraphbackContext): string[] | ""*

Defined in KnexDBDataProvider.ts:121

Parameters:

NameType
contextGraphbackContext

Returns: string[] | ""*


update#

update(data: Type, context: GraphbackContext): Promise‹Type›

Defined in KnexDBDataProvider.ts:41

Parameters:

NameType
dataType
contextGraphbackContext

Returns: Promise‹Type›


Private usePage#

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

Defined in KnexDBDataProvider.ts:127

Parameters:

NameType
queryQueryBuilder
page?GraphbackPage

Returns: QueryBuilder‹any, any›