Version: 1.0

MongoDBDataProvider

Graphback provider that connnects to the MongoDB database

Type parameters#

Type

Hierarchy#

  • MongoDBDataProvider

Implements#

  • GraphbackDataProvider‹Type›

Index#

Constructors#

Properties#

Methods#

Constructors#

constructor#

+ new MongoDBDataProvider(model: ModelDefinition, db: any): MongoDBDataProvider

Defined in MongoDBDataProvider.ts:17

Parameters:

NameType
modelModelDefinition
dbany

Returns: MongoDBDataProvider

Properties#

Protected collectionName#

collectionName: string

Defined in MongoDBDataProvider.ts:15


Protected db#

db: Db

Defined in MongoDBDataProvider.ts:14


Protected fieldTransformMap#

fieldTransformMap: FieldTransformMap

Defined in MongoDBDataProvider.ts:17


Protected tableMap#

tableMap: ModelTableMap

Defined in MongoDBDataProvider.ts:16

Methods#

batchRead#

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

Defined in MongoDBDataProvider.ts:127

Parameters:

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

Returns: Promise‹Type[][]›


Protected buildProjectionOption#

buildProjectionOption(selectedFields: string[]): object

Defined in MongoDBDataProvider.ts:153

Parameters:

NameType
selectedFieldsstring[]

Returns: object

  • [field]: number = 1

count#

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

Defined in MongoDBDataProvider.ts:123

Parameters:

NameType
filter?QueryFilter

Returns: Promise‹number›


create#

create(data: Type): Promise‹Type›

Defined in MongoDBDataProvider.ts:30

Parameters:

NameType
dataType

Returns: Promise‹Type›


delete#

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

Defined in MongoDBDataProvider.ts:78

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


findBy#

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

Defined in MongoDBDataProvider.ts:110

Parameters:

NameType
args?FindByArgs
selectedFields?string[]

Returns: Promise‹Type[]›


findOne#

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

Defined in MongoDBDataProvider.ts:96

Parameters:

NameType
filterPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


Private sortQuery#

sortQuery(query: Cursor‹any›, orderBy: GraphbackOrderBy): Cursor‹any›

Defined in MongoDBDataProvider.ts:174

Parameters:

NameType
queryCursor‹any›
orderByGraphbackOrderBy

Returns: Cursor‹any›


update#

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

Defined in MongoDBDataProvider.ts:50

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


Private usePage#

usePage(query: Cursor‹any›, page?: GraphbackPage): Promise‹any[]›

Defined in MongoDBDataProvider.ts:191

Parameters:

NameType
queryCursor‹any›
page?GraphbackPage

Returns: Promise‹any[]›


Private verifyMongoDBPrimaryKey#

verifyMongoDBPrimaryKey(modelName: string, primaryKey: FieldDescriptor): void

Defined in MongoDBDataProvider.ts:167

Parameters:

NameType
modelNamestring
primaryKeyFieldDescriptor

Returns: void