Skip to content

@sourceloop/core / Exports / BelongsToRestResolver

Class: BelongsToRestResolver<T, S>

Type parameters

Name Type
T extends Entity
S extends Entity

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BelongsToRestResolver<T, S>(context)

Type parameters

Name Type
T extends Entity<T>
S extends Entity<S>

Parameters

Name Type
context Context

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:29

Properties

context

Private context: Context

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:31


type

type: RelationType = RelationType.belongsTo

Implementation of

IRestResolver.type

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:28

Methods

addConditionToScope

Private addConditionToScope(ids, scope?): Promise<{ where: Where<AnyObject> }>

Parameters

Name Type
ids T[keyof T][]
scope? Filter<S>

Returns

Promise<{ where: Where<AnyObject> }>

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:93


getService

Private getService(config): Promise<ModifiedRestService<S>>

Parameters

Name Type
config RestRelationConfig

Returns

Promise<ModifiedRestService<S>>

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:115


link(-): Promise<T>

It takes a parent object, looks up the foreign key on the parent, and then uses that foreign key to look up and link the related object in the resolvedDataMap

Parameters

Name Type Description
- RestLinkerParams<T, S> & { relationMetadata: BelongsToDefinition } relationMetadata is the metadata for the relation being linked.

Returns

Promise<T>

The parent object with the relationName property set to the resolvedDataMap.get(parent[keyFrom])

Implementation of

IRestResolver.link

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:78


resolve

resolve(-): Promise<Map<S[keyof S] | T[keyof T], S>>

It takes the results of the query, finds the foreign key in each result, and then uses that key to find the related record in the related service

Parameters

Name Type Description
- RestResolverParams<T, S> & { relationMetadata: BelongsToDefinition } relationConfig is the configuration object for the relation.

Returns

Promise<Map<S[keyof S] | T[keyof T], S>>

A map of related records.

Implementation of

IRestResolver.resolve

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:39


toPascalCase

Private toPascalCase(str): string

Parameters

Name Type
str string

Returns

string

Defined in

packages/core/src/components/proxy-builder/services/rest-resolvers/belongs-to-resolver.service.ts:107