Version: 0.16.x

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:19

Parameters:

NameType
modelModelDefinition
dbany

Returns: MongoDBDataProvider

Properties

Protected coerceTSFields

coerceTSFields: boolean

Defined in MongoDBDataProvider.ts:19


Protected collectionName

collectionName: string

Defined in MongoDBDataProvider.ts:16


Protected db

db: Db

Defined in MongoDBDataProvider.ts:15


Protected fieldTransformMap

fieldTransformMap: FieldTransformMap

Defined in MongoDBDataProvider.ts:18


Protected tableMap

tableMap: ModelTableMap

Defined in MongoDBDataProvider.ts:17

Methods

batchRead

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

Defined in MongoDBDataProvider.ts:124

Parameters:

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

Returns: Promise‹Type[][]›


Protected buildProjectionOption

buildProjectionOption(selectedFields: string[]): object

Defined in MongoDBDataProvider.ts:150

Parameters:

NameType
selectedFieldsstring[]

Returns: object

  • [field]: number = 1

count

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

Defined in MongoDBDataProvider.ts:120

Parameters:

NameType
filter?QueryFilter

Returns: Promise‹number›


create

create(data: Type): Promise‹Type›

Defined in MongoDBDataProvider.ts:33

Parameters:

NameType
dataType

Returns: Promise‹Type›


delete

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

Defined in MongoDBDataProvider.ts:77

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


findBy

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

Defined in MongoDBDataProvider.ts:108

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:171

Parameters:

NameType
queryCursor‹any›
orderByGraphbackOrderBy

Returns: Cursor‹any›


update

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

Defined in MongoDBDataProvider.ts:53

Parameters:

NameType
dataPartial‹Type›
selectedFields?string[]

Returns: Promise‹Type›


Private usePage

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

Defined in MongoDBDataProvider.ts:188

Parameters:

NameType
queryCursor‹any›
page?GraphbackPage

Returns: Promise‹any[]›


Private verifyMongoDBPrimaryKey

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

Defined in MongoDBDataProvider.ts:164

Parameters:

NameType
modelNamestring
primaryKeyFieldDescriptor

Returns: void