IRegionModuleService
The main service interface for the Region Module.
Methods
create
**create**(data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)[]>
This method creates regions.
Example
Parameters
The regions to be created.
Returns
The created regions.
**create**(data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)>
This method creates a region.
Example
Parameters
The region to be created.
Returns
The created region.
upsert
**upsert**(data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)[]>
This method updates or creates regions if they don't exist.
Example
Parameters
The attributes in the regions to be created or updated.
Returns
The created or updated regions.
**upsert**(data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)>
This method updates or creates a region if it doesn't exist.
Example
Parameters
The attributes in the region to be created or updated.
Returns
The created or updated region.
update
**update**(id, data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)>
This method updates an existing region.
Example
Parameters
id
stringRequiredThe attributes to update in the region.
Returns
The updated region.
**update**(selector, data, sharedContext?): Promise<[RegionDTO](types.RegionDTO.mdx)[]>
This method updates existing regions.
Example
Parameters
The filters to apply on the retrieved regions.
The attributes to update in the region.
Returns
The updated regions.
delete
**delete**(ids, sharedContext?): Promise<void>
This method deletes regions by their IDs.
Example
Parameters
ids
string[]RequiredReturns
Promise
Promise<void>Required**delete**(id, sharedContext?): Promise<void>
This method deletes a region by its ID.
Example
Parameters
id
stringRequiredReturns
Promise
Promise<void>Requiredretrieve
This method retrieves a region by its ID.
Example
A simple example that retrieves a region by its ID:
To specify relations that should be retrieved:
Parameters
id
stringRequiredconfig
FindConfig<RegionDTO>The configurations determining how the region is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a region.
config
FindConfig<RegionDTO>select
or relations
, accept the
attributes or relations associated with a region.Returns
The retrieved region.
list
This method retrieves a paginated list of regions based on optional filters and configuration.
Example
To retrieve a list of regions using their IDs:
To specify relations that should be retrieved within the regions:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableRegionPropsThe filters to apply on the retrieved regions.
filters
FilterableRegionPropsconfig
FindConfig<RegionDTO>The configurations determining how the region is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a region.
config
FindConfig<RegionDTO>select
or relations
, accept the
attributes or relations associated with a region.Returns
The list of regions.
listAndCount
This method retrieves a paginated list of regions along with the total count of available regions satisfying the provided filters.
Example
To retrieve a list of regions using their IDs:
To specify relations that should be retrieved within the regions:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableRegionPropsThe filters to apply on the retrieved regions.
filters
FilterableRegionPropsconfig
FindConfig<RegionDTO>The configurations determining how the region is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a region.
config
FindConfig<RegionDTO>select
or relations
, accept the
attributes or relations associated with a region.Returns
The list of regions along with their total count.
retrieveCountry
This method retrieves a country by its 2 character ISO code.
Example
A simple example that retrieves a country by its 2 character ISO code:
To specify relations that should be retrieved:
Parameters
countryId
stringRequiredconfig
FindConfig<RegionCountryDTO>The configurations determining how the country is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a country.
config
FindConfig<RegionCountryDTO>select
or relations
, accept the
attributes or relations associated with a country.Returns
The retrieved country.
listCountries
This method retrieves a paginated list of countries based on optional filters and configuration.
Example
To retrieve a list of countries using their IDs:
To specify relations that should be retrieved within the countries:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableRegionCountryPropsThe filters to apply on the retrieved countries.
filters
FilterableRegionCountryPropsconfig
FindConfig<RegionCountryDTO>The configurations determining how the country is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a country.
config
FindConfig<RegionCountryDTO>select
or relations
, accept the
attributes or relations associated with a country.Returns
The list of countries.
listAndCountCountries
This method retrieves a paginated list of countries along with the total count of available countries satisfying the provided filters.
Example
To retrieve a list of countries using their IDs:
To specify relations that should be retrieved within the countries:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableRegionCountryPropsThe filters to apply on the retrieved countries.
filters
FilterableRegionCountryPropsconfig
FindConfig<RegionCountryDTO>The configurations determining how the country is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a country.
config
FindConfig<RegionCountryDTO>select
or relations
, accept the
attributes or relations associated with a country.Returns
The list of countries along with their total count.
softDelete
This method soft deletes a region by its IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
regionIds
string[]Requiredconfig
SoftDeleteReturn<TReturnableLinkableKeys>An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted.
config
SoftDeleteReturn<TReturnableLinkableKeys>Returns
Promise
Promise<void | Record<string, string[]>>RequiredAn object that includes the IDs of related records that were also soft deleted, such as the ID of the associated country.
The object's keys are the ID attribute names of the region entity's relations, such as country_id
, and its value is an array of strings, each being the ID of a record associated
with the region through this relation, such as the IDs of associated countries.
If there are no related records, the promise resolves to void
.
Promise
Promise<void | Record<string, string[]>>Requiredcountry_id
, and its value is an array of strings, each being the ID of a record associated
with the region through this relation, such as the IDs of associated countries.
If there are no related records, the promise resolves to void
.restore
This method restores soft deleted regions by their IDs.
Example
Type Parameters
TReturnableLinkableKeys
stringRequiredParameters
regionIds
string[]Requiredconfig
RestoreReturn<TReturnableLinkableKeys>Configurations determining which relations to restore along with each of the region. You can pass to its returnLinkableKeys
property any of the region's relation attribute names, such as countries
.
config
RestoreReturn<TReturnableLinkableKeys>returnLinkableKeys
property any of the region's relation attribute names, such as countries
.Returns
Promise
Promise<void | Record<string, string[]>>RequiredAn object that includes the IDs of related records that were restored, such as the ID of associated countries.
The object's keys are the ID attribute names of the region entity's relations, such as country_id
,
and its value is an array of strings, each being the ID of the record associated with the region through this relation,
such as the IDs of associated countries.
If there are no related records restored, the promise resolves to void
.
Promise
Promise<void | Record<string, string[]>>Requiredcountry_id
,
and its value is an array of strings, each being the ID of the record associated with the region through this relation,
such as the IDs of associated countries.
If there are no related records restored, the promise resolves to void
.