Skip to main content

CountryService

CountryService

Contains methods relating to Country entities.

Signature
class CountryService {
constructor(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, translator: TranslatorService)
findAll(ctx: RequestContext, options?: ListQueryOptions<Country>, relations: RelationPaths<Country> = []) => Promise<PaginatedList<Translated<Country>>>;
findOne(ctx: RequestContext, countryId: ID, relations: RelationPaths<Country> = []) => Promise<Translated<Country> | undefined>;
findAllAvailable(ctx: RequestContext) => Promise<Array<Translated<Country>>>;
findOneByCode(ctx: RequestContext, countryCode: string) => Promise<Translated<Country>>;
create(ctx: RequestContext, input: CreateCountryInput) => Promise<Translated<Country>>;
update(ctx: RequestContext, input: UpdateCountryInput) => Promise<Translated<Country>>;
delete(ctx: RequestContext, id: ID) => Promise<DeletionResponse>;
}

constructor

method
(connection: TransactionalConnection, listQueryBuilder: ListQueryBuilder, translatableSaver: TranslatableSaver, eventBus: EventBus, translator: TranslatorService) => CountryService

findAll

method
(ctx: RequestContext, options?: ListQueryOptions<Country>, relations: RelationPaths<Country> = []) => Promise<PaginatedList<Translated<Country>>>

findOne

method
(ctx: RequestContext, countryId: ID, relations: RelationPaths<Country> = []) => Promise<Translated<Country> | undefined>

findAllAvailable

method
(ctx: RequestContext) => Promise<Array<Translated<Country>>>

Returns an array of enabled Countries, intended for use in a public-facing (ie. Shop) API.

findOneByCode

method
(ctx: RequestContext, countryCode: string) => Promise<Translated<Country>>

Returns a Country based on its ISO country code.

create

method
(ctx: RequestContext, input: CreateCountryInput) => Promise<Translated<Country>>

update

method
(ctx: RequestContext, input: UpdateCountryInput) => Promise<Translated<Country>>

delete

method
(ctx: RequestContext, id: ID) => Promise<DeletionResponse>