Members
(constant) SlashDBConsumer
Use to access params passed though use of SlashDBProvider.
useContext hook from React can be used instead of SlashDBConsumer in practice
such as:
import { useContext} from 'react';
import { SlashDBContext } from './Context';
useContext(SlashDBContext);
- Source:
(constant) SlashDBContext
Create custom Context to be used with provider, consumer and useContext hook. For param sharing without need to pass it
down from parent to child at each level of the component tree.
- Source:
Methods
checkClientAuthStatus(instanceName) → {boolean}
Helper to check client authentication status - used in Auth clientIsAuthenticated method
Parameters:
Name | Type | Description |
---|---|---|
instanceName |
string | the SlashDB client instance check |
Returns:
flag indicating if client is currently authenticated to SlashDB server
- Type
- boolean
removeSdbClients(instanceNameopt)
Helper to logout and remove SlashDB clients - used in Auth logout method
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
instanceName |
string |
<optional> |
the SlashDB client instance to log out; if undefined, all clients are logged out |
SlashDBProvider(setUpOptions)
Custom React component for build in use of Provider from createContext. Use:
by defining SlashDBProvider element in project we can pass params to it which will be accessable thoughout project.
See SlashDBConsumer for more info on how to use params passed. I.e. Wrap App component so that context data is avaliable
throughout application.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUpOptions |
Object | holds the setup parameter: setUpOptions is an object of key value pairs. Properties
|
- Source:
useDataDiscovery(database, resource, defaultFilteropt, instanceNameopt) → {array}
Hook for accessing SlashDB Data Discovery feature
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
database |
string | name of the database containing the desired resource/table |
||
resource |
string | the resource/table to discover |
||
defaultFilter |
string | DataDiscoveryFilter |
<optional> |
optional string/DataDiscovery filter object containing a default filter for the resource |
|
instanceName |
string |
<optional> |
default | optional name of SlashDB client that has been previously created with useSetUp() hook; default is 'default' |
Returns:
array, first element is data for given resource/table and subsequent elements are function references to execute on-demand GET/POST/PUT/DELETE calls on the resource
- Type
- array
useExecuteQuery(queryName, defaultParamsopt, defHttpMethod, instanceNameopt) → {array}
Hook for accessing SlashDB SQL Pass-Thru feature
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
queryName |
string | name of the query to execute |
||
defaultParams |
string | SQLPassThruFilter |
<optional> |
optional string/SQLPassThruFilter filter object containing parameters for the query |
|
defHttpMethod |
string | get | optional parameter to set the HTTP method used by the query; default is 'get' |
|
instanceName |
string |
<optional> |
default | optional name of SlashDB client that has been previously created with useSetUp() hook; default is 'default' |
Returns:
array, first element is data for given resource/table and second element is function reference to execute query on demand
- Type
- array
useFetcher(instanceNameopt) → {fetch}
Create a fetch function with SlashDB credentials, after a successful login.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
instanceName |
string |
<optional> |
default | a name to identify the client in the registry; if not provided, will be named 'default' |
Returns:
a reference to the fetch client with updated credential headers.
- Type
- fetch
useSetUp(instanceNameopt, configopt) → {SlashDBClient}
Create a SlashDB client object for use with hooks and store in a local registry. If no parameters are provided, create a client object using
the parameters configured with the SlashDBProvider component
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
instanceName |
string |
<optional> |
default | a name to identify the client in the registry; if not provided, will be named 'default' |
||||||||||||||||||||||||||||||||
config |
Object |
<optional> |
holds the setup parameter: config is an object of key value pairs. Properties
|
Returns:
a reference to the SlashDB client that was created
- Type
- SlashDBClient