Skip to main content

Create

Basic​

This method interacts with the Basic Create endpoint to create a resource.

Usage​

const response = await userService.create({ name: 'Lucy', role: 'user', public: true });

Parameters​

ParameterTypeDescription
dataobjectData for creating the resource.
optionsCreateOptions (optional)Additional options for customizing the create operation.
axiosRequestConfigAxiosRequestConfig (optional)Axios request configuration for fine-tuning the HTTP request.
interface CreateOptions {
includePermissions?: boolean; // Include permissions in the response.
}

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.
dataModelParsed data represented as an array of Model instances.
headersobject[AxiosHeaders]Axios headers associated with the response.
{
success: true,
status: 201,
raw: {
_id: '79c8c567b05e986509d55733a',
name: 'Lucy',
role: 'user',
public: true,
_permissions: {}
},
data: Model {
_id: [Getter/Setter],
name: [Getter/Setter],
role: [Getter/Setter],
public: [Getter/Setter],
_permissions: [Getter/Setter]
},
headers: Object [AxiosHeaders] {}
}

Advanced​

This method interacts with the Advanced Create endpoint to create a resource with advanced options.

Usage​

const response = await userService.create({ name: 'Lucy', role: 'user', public: true }, { select: ['name'] });

Parameters​

ParameterTypeDescription
dataobjectData for creating the resource.
argsCreateAdvancedArgs (optional)Advanced arguments for controlling the create operation.
optionsCreateAdvancedOptions (optional)Additional options for customizing the advanced create operation.
axiosRequestConfigAxiosRequestConfig (optional)Axios request configuration for fine-tuning the HTTP request.
interface CreateAdvancedArgs {
select?: Projection; // Projection for selecting specific fields.
populate?: Populate[] | Populate | string; // Data to populate in the response.
}

interface CreateAdvancedOptions {
includePermissions?: boolean; // Include permissions in the response.
populateAccess?: PopulateAccess; // Options for populating access-related data.
}

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.
dataModelParsed data represented as an array of Model instances.
headersobject[AxiosHeaders]Axios headers associated with the response.
{
success: true,
status: 201,
raw: {
_id: '79c8c567b05e986509d55733a',
name: 'Lucy',
_permissions: {}
},
data: Model {
_id: [Getter/Setter],
name: [Getter/Setter],
_permissions: [Getter/Setter]
},
headers: Object [AxiosHeaders] {}
}