BaseApiController Class
Constructor
BaseApiController
()
Methods
delete
-
cb
Deletes the resource with the specified ID from the URI path ":id".
Parameters:
-
cb
Function
get
-
cb
Retrieves a resource by ID where :id is a path parameter
Parameters:
-
cb
Function
getAll
-
cb
Retrieves one or more resources from a collection. The endpoint supports the following query string parameters:
- $select - A comma separated list of key/value pairs where a value of 1 indicates the field will be returned and 0 indicates the absensence. $select=_id=1,name=1,description=0
- $order - A comma separated list of key/value pairs where a value of 1 indicates ascending a value of 0 or less indicates descending. $order=name=1,created_date=0
- $limit - An integer representing the maximum number of results to return
- $offset - An integer representing the number of items to skip before returning results
- $where - Currently not supported
Parameters:
-
cb
Function
getPostDto
()
Object
Retrieves the request DTO. The function ensures that the id field is removed.
Returns:
handleDelete
-
cb
Creates a handler that can be used to prepare a response for GET operations. When the result is NULL a 404 is generated. Otherwise a 200 response along with the object serialized as JSON is the generated response
Parameters:
-
cb
Function
Returns:
That can prepare a response and execute the callback
handleDelete
-
cb
Creates a handler that can be used to prepare a response for DELETE operations. When the item cannot be found a 404 is issued. When the object is successfully delete a 204 status is provided
Parameters:
-
cb
Function
Returns:
That can prepare a response and execute the callback
handleSave
-
cb
Creates a handler that can be used to prepare a response for POST or PUT operations. Upon successful create a 201 status code is returned. Upon successful update a 200 status code is returned. Validation errors are expected to be handled by the global error handler and should return 400
Parameters:
-
cb
Function
Returns:
That can prepare a response and execute the callback
notFound
()
Calls back to the request handler with an error representing a 404 not found
post
-
cb
Creates a resource
Parameters:
-
cb
Function
processOrder
-
rawOrder
Processes the value of a $order query string variable
Parameters:
-
rawOrder
String
Returns:
Contains the order statement and an array of failures
processQuery
()
Object
Prcoess the query string and builds the options for passing to the object service
Returns:
The options representing the query
processSelect
-
rawSelect
Processes the value of a $select query string variable
Parameters:
-
rawSelect
String
Returns:
Contains the select statement and an array of failures
processWhere
-
q
Processes the query string to develop the where clause for the query request
Parameters:
-
q
ObjectThe hash of all query parameters from the request
Returns:
put
-
cb
Updates a resource with the ID specified in the body of the request.
Parameters:
-
cb
Function
Properties
FIELD_OFF
String
static
Indicates if a field should be part of the projection
FIELD_ON
String
static
Indicates if a field should be part of the projection
MULTI_DELIMITER
String
static
The delimiter used when multiple values are provided for a single query parameter