Constructor
new DataDiscoveryResource(db, resource, clientObjopt)
Create a DataDiscoveryResource
object for a given SlashDB instance
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
db |
string | DataDiscoveryDatabase | name of database to interact with via this instance, or a previously configured |
|
resource |
string | name of resource (table) to interact with via this instance |
|
clientObj |
SlashDBClient |
<optional> |
an optional configured |
- Source:
Throws:
-
-
if
db
parameter is aDataDiscoveryObject
that is missingdbName
property or has invaliddbName
property - Type
- ReferenceError | TypeError
-
-
-
if
db
parameter is: not aDataDiscoveryObject
/not a string/parses to a number - Type
- TypeError
-
-
-
if
resource
parameter is not a string or an empty string, or parses to a number - Type
- TypeError
-
-
-
if no
clientObj
parameter was given, and a validSlashDBClient
object is not contained withindb
parameter,
which must be aDataDiscoveryDatabase
object ifclientObj
is omitted - Type
- ReferenceError
-
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 | DataDiscoveryFilter |
<optional> |
an optional string containing a URI segment with SQL query parameters/values and URL query parameters |
- 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 aDataDiscoveryFilter
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. |
- 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. |
- 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 |
- 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 |
- 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 |
- 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 |
- 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