From b2f67de5aba8e6d927163ca248da23c039ba0dd3 Mon Sep 17 00:00:00 2001 From: ctjong Date: Tue, 6 Mar 2018 00:20:05 -0800 Subject: [PATCH] [rm] api ref updates --- Readme.md | 57 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Readme.md b/Readme.md index 318a417..49d1eda 100644 --- a/Readme.md +++ b/Readme.md @@ -432,31 +432,32 @@ Operators: ## API Reference -An Orion application object is an extension of an [Express application object](https://expressjs.com/en/4x/api.html#app), meaning all default properties and methods from Express are inherited to the object. All Express's static methods (**json()**, **static()**, **Router()**, **urlencoded()**) are also injected into the application object. In addition to those, here are some more methods that are accessible from the object: - -- **Methods** - - **setupApiEndpoints()** - Setup REST API endpoints to do CRUD operations. See [API Endpoints](#api-endpoints) for the list of endpoints created from this function call. - - **start(port, callback)** - Start the server. This function is calling Express's **listen()**. - - **port** - (Optional) Optional port to start the server at. - - **callback** - (Optional) Callback to execute after the start process is complete. - - **return** - A server application object, returned from Express's **listen()**. - - **findById(originalReq, entity, id, callback)** - Execute a "find by ID" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. - - **originalReq** - (Required) Express Request object. - - **entity** - (Required) Target entity. - - **id** - (Required) Target record id. - - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. - - **findByCondition(originalReq, entity, orderByField, skip, take, condition, callback)** - Execute a "find by condition" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. - - **originalReq** - (Required) Express Request object. - - **entity** - (Required) Target entity. - - **orderByField** - (Required) The field to order the results by. You can add "~" in front of the field name to sort in descending order. - - **skip** - (Required) Number of records to skip. Used for pagination. - - **take** - (Required) Number of records to take. Used for pagination. - - **condition** - (Required) Condition string to find the target records. See [Condition Syntax](#condition-syntax) for more details on how to write the condition. - - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. - - **findAll(originalReq, entity, orderByField, skip, take, callback)** - Execute a "find all" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. - - **originalReq** - (Required) Express Request object. - - **entity** - (Required) Target entity. - - **orderByField** - (Required) The field to order the results by. You can add "~" in front of the field name to sort in descending order. - - **skip** - (Required) Number of records to skip. Used for pagination. - - **take** - (Required) Number of records to take. Used for pagination. - - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. \ No newline at end of file +An Orion application object is an extension of an [Express application object](https://expressjs.com/en/4x/api.html#app), meaning all default properties and methods from Express are inherited to the object. Express's static methods (**json()**, **static()**, **Router()**, **urlencoded()**) are exposed through the **app.express** property. + +Here are some additional methods that are accessible from an Orion application object: + +- **setupApiEndpoints()** - Setup REST API endpoints to do CRUD operations. See [API Endpoints](#api-endpoints) for the list of endpoints created from this function call. +- **start(port, callback)** - Start the server. This function is calling Express's **listen()**. + - **port** - (Optional) Optional port to start the server at. + - **callback** - (Optional) Callback to execute after the start process is complete. + - **return** - A server application object, returned from Express's **listen()**. +- **findById(originalReq, entity, id, callback)** - Execute a "find by ID" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. + - **originalReq** - (Required) Express Request object. + - **entity** - (Required) Target entity. + - **id** - (Required) Target record id. + - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. +- **findByCondition(originalReq, entity, orderByField, skip, take, condition, callback)** - Execute a "find by condition" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. + - **originalReq** - (Required) Express Request object. + - **entity** - (Required) Target entity. + - **orderByField** - (Required) The field to order the results by. You can add "~" in front of the field name to sort in descending order. + - **skip** - (Required) Number of records to skip. Used for pagination. + - **take** - (Required) Number of records to take. Used for pagination. + - **condition** - (Required) Condition string to find the target records. See [Condition Syntax](#condition-syntax) for more details on how to write the condition. + - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. +- **findAll(originalReq, entity, orderByField, skip, take, callback)** - Execute a "find all" action. This does the same thing as the GET endpoint but this one can be executed directly from server code. + - **originalReq** - (Required) Express Request object. + - **entity** - (Required) Target entity. + - **orderByField** - (Required) The field to order the results by. You can add "~" in front of the field name to sort in descending order. + - **skip** - (Required) Number of records to skip. Used for pagination. + - **take** - (Required) Number of records to take. Used for pagination. + - **callback** - (Required) Callback fuction. This passes in a response object as parameter, which has the same structure as the return value of the GET endpoint. \ No newline at end of file diff --git a/package.json b/package.json index d6a0010..95ad492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "orion-api", - "version": "1.2.2", + "version": "1.2.3", "description": "REST API server application", "main": "index.js", "repository": {