Class: SQLPassThruQuery

SQLPassThruQuery(queryID, clientObj, methodsopt, paramsopt)

Executes HTTP requests for SlashDB SQL Pass-Thru functionality. Extends the BaseRequestHandler class
for most methods.

Constructor

new SQLPassThruQuery(queryID, clientObj, methodsopt, paramsopt)

Create a SQLPassThruQuery object for a given SlashDB instance

Parameters:
Name Type Attributes Default Description
queryID string

ID of the query to execute, as registered in the SlashDB instance

clientObj SlashDBClient

a configured SlashDBClient object

methods Object <optional>
null

optional object of key/value pairs specifying which HTTP methods the query supports (e.g. {GET:true, POST:false})

params Object <optional>
null

optional array of strings specifying names of parameters (e.g. ['FirstName','LastName'])

Source:
Throws:
  • if queryID not a string

    Type
    TypeError
  • if queryID contains '/' character

    Type
    SyntaxError
  • if queryID contains spaces or parses to number

    Type
    SyntaxError

Extends

Methods

_buildEndpointString(pathopt) → {string}

Builds the full endpoint to the requested resource. Meant for internal use only.

Parameters:
Name Type Attributes Description
path string | SQLPassThruFilter <optional>

an optional string containing a URI segment with SQL query parameters/values and URL query parameters
(e.g. /FirstName/Tim?distinct=true), or a SQLPassThruFilter object that contains all the query details

Overrides:
Source:
Throws:
  • if no SlashDBClient object is found attached to this object

    Type
    ReferenceError
  • if path parameter is an empty string

    Type
    SyntaxError
  • if path parameter is neither a string or a SQLPassThruFilter object

    Type
    TypeError
Returns:

the full endpoint

Type
string

accept(format) → {BaseRequestHandler}

Sets Accept header value for HTTP requests

Parameters:
Name Type Description
format string

a valid MIME type (e.g. 'application/json'), or a key value of the validMimeTypes property in this class (e.g. 'json','csv')

Overrides:
Source:
Throws:
  • if format missing

    Type
    TypeError
  • if format is not string

    Type
    TypeError
Returns:

this object

Type
BaseRequestHandler

contentType(format) → {BaseRequestHandler}

Sets Content-Type header value for HTTP POST/PUT requests

Parameters:
Name Type Description
format string

a valid MIME type (e.g. 'application/json'), or a key value of the validMimeTypes property in this class (e.g. 'json','csv')

Overrides:
Source:
Throws:
  • if format missing

    Type
    TypeError
  • if format is not string

    Type
    TypeError
Returns:

this object

Type
BaseRequestHandler

(async) delete(pathopt) → {Promise}

Executes HTTP DELETE request

Parameters:
Name Type Attributes Description
path string | DataDiscoveryFilter | SQLPassThruFilter <optional>

an optional string containing a URI segment with URL query parameters
(e.g. /Customer/FirstName/Tim?distinct=true), or a DataDiscoveryFilter/SQLPassThruFilter object that contains all the query details

Overrides:
Source:
Returns:

promise containing HTTP response status and data

Type
Promise

(async) get(pathopt) → {Promise}

Executes HTTP GET request

Parameters:
Name Type Attributes Description
path string | DataDiscoveryFilter | SQLPassThruFilter <optional>

an optional string containing a URI segment with URL query parameters
(e.g. /Customer/FirstName/Tim?distinct=true), or a DataDiscoveryFilter/SQLPassThruFilter object that contains all the query details

Overrides:
Source:
Returns:

promise containing HTTP response status and data

Type
Promise

getHeaders()

Gets authentication common header for HTTP requests

Overrides:
Source:

(async) post(data, pathopt) → {Promise}

Executes HTTP POST request

Parameters:
Name Type Attributes Description
data string | object

an object or string containing data values to include in the POST request body. Can be JSON, an object, or CSV/XML formatted string

path string | DataDiscoveryFilter | SQLPassThruFilter <optional>

an optional string containing a URI segment with URL query parameters
(e.g. /Customer/FirstName/Tim?distinct=true), or a DataDiscoveryFilter/SQLPassThruFilter object that contains all the query details. Not used under normal
circumstances.

Overrides:
Source:
Returns:

promise containing HTTP response status and data

Type
Promise

(async) put(data, path) → {Promise}

Executes HTTP PUT request

Parameters:
Name Type Description
data string | object

an object or string containing data values to include in the PUT request body. Can be JSON, an object, or CSV/XML formatted string

path string | DataDiscoveryFilter | SQLPassThruFilter | null | undefined

a string containing a URI segment with URL query parameters
(e.g. /Customer/FirstName/Tim?distinct=true), or a DataDiscoveryFilter/SQLPassThruFilter object that contains all the query details. Set to null or undefined
if not required.

Overrides:
Source:
Returns:

promise containing HTTP response status and data

Type
Promise

setExtraHeaders(headersObj) → {BaseRequestHandler}

Sets arbitrary custom header value for HTTP requests

Parameters:
Name Type Description
headersObj object

an object containing key/value pairs of header properties

Overrides:
Source:
Throws:
  • headersObj is not an object

    Type
    TypeError
  • if the value of a key/value pair is not a string or number

    Type
    TypeError
Returns:

this object

Type
BaseRequestHandler