Skip to main content

Read

Basic​

This method retrieves a single resource sub-document resource by its identifier.

Usage​

const response = await services.userService
.id("79c8c567b05e986509d55733a")
.subs("statusHistory")
.read('95ac058c573be9879d059c663');

Parameters​

ParameterTypeDescription
subIdstringThe ID of the sub-document resource to be retrieved.
axiosRequestConfigAxiosRequestConfig (optional)Axios request configuration for fine-tuning the HTTP request.

Response​

PropTypeDescription
successbooleanIndicates whether the request was successful.
statusnumberHTTP status code of the response.
messagestringA message providing additional information about the response, especially in case of errors.
rawobjectRaw data received from the server.
dataobjectRaw data received from the server.
headersobject[AxiosHeaders]Axios headers associated with the response.
{
success: true,
status: 200,
raw: {
_id: '95ac058c573be9879d059c663',
name: 'premium',
active: true
},
data: {
_id: '95ac058c573be9879d059c663',
name: 'premium',
active: true
},
headers: Object [AxiosHeaders] {}
}

Advanced​

This method retrieves a single resource sub-document resource by its identifier with advanced options.

Usage​

const response = await services.userService
.id("79c8c567b05e986509d55733a")
.subs("statusHistory")
.readAdvanced('95ac058c573be9879d059c663', { select: ['name'] });

Parameters​

ParameterTypeDescription
subIdstringThe ID of the sub-document resource to be retrieved.
args{ select?: string[]; populate?: any } (optional)Advanced arguments for controlling the resource retrieval.
axiosRequestConfigAxiosRequestConfig (optional)Axios request configuration for fine-tuning the HTTP request.

Response​

PropTypeDescription
successbooleanIndicates whether the request was successful.
statusnumberHTTP status code of the response.
messagestringA message providing additional information about the response, especially in case of errors.
rawobjectRaw data received from the server.
dataobjectRaw data received from the server.
headersobject[AxiosHeaders]Axios headers associated with the response.
{
success: true,
status: 200,
raw: {
_id: '95ac058c573be9879d059c663',
name: 'premium'
},
data: {
_id: '95ac058c573be9879d059c663',
name: 'premium'
},
headers: Object [AxiosHeaders] {}
}