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
Parameter | Type | Description |
---|---|---|
data | object | Data for creating the resource. |
options | CreateOptions (optional) | Additional options for customizing the create operation. |
axiosRequestConfig | AxiosRequestConfig (optional) | Axios request configuration for fine-tuning the HTTP request. |
interface CreateOptions {
includePermissions?: boolean; // Include permissions in the response.
}
Response
Prop | Type | Description |
---|---|---|
success | boolean | Indicates whether the request was successful. |
status | number | HTTP status code of the response. |
message | string | A message providing additional information about the response, especially in case of errors. |
raw | object | Raw data received from the server. |
data | Model | Parsed data represented as an array of Model instances. |
headers | object[AxiosHeaders] | Axios headers associated with the response. |
- 201
- 400
- 401
{
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] {}
}
{
success: false,
status: 400,
message: 'Bad Request',
headers: Object [AxiosHeaders] {}
}
{
success: false,
status: 401,
message: 'Unauthorized',
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
Parameter | Type | Description |
---|---|---|
data | object | Data for creating the resource. |
args | CreateAdvancedArgs (optional) | Advanced arguments for controlling the create operation. |
options | CreateAdvancedOptions (optional) | Additional options for customizing the advanced create operation. |
axiosRequestConfig | AxiosRequestConfig (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
Prop | Type | Description |
---|---|---|
success | boolean | Indicates whether the request was successful. |
status | number | HTTP status code of the response. |
message | string | A message providing additional information about the response, especially in case of errors. |
raw | object | Raw data received from the server. |
data | Model | Parsed data represented as an array of Model instances. |
headers | object[AxiosHeaders] | Axios headers associated with the response. |
- 201
- 400
- 401
{
success: true,
status: 201,
raw: {
_id: '79c8c567b05e986509d55733a',
name: 'Lucy',
_permissions: {}
},
data: Model {
_id: [Getter/Setter],
name: [Getter/Setter],
_permissions: [Getter/Setter]
},
headers: Object [AxiosHeaders] {}
}
{
success: false,
status: 400,
message: 'Bad Request',
headers: Object [AxiosHeaders] {}
}
{
success: false,
status: 401,
message: 'Unauthorized',
headers: Object [AxiosHeaders] {}
}