Class: SQLPassThruFilter

SQLPassThruFilter(paramsopt, urlPlaceholderopt)

Class for creating URL strings for SlashDB SQL Pass-Thru functionality

Constructor

new SQLPassThruFilter(paramsopt, urlPlaceholderopt)

Create a SQLPassThruFilter object for making SlashDB-compatible URL strings

Parameters:
Name Type Attributes Default Description
params Object <optional>

optional object of key/value pairs representing SQL query parameters to instantiate this object with

urlPlaceholder string <optional>
__

a string that contains a character(s) to set for the placeholder query parameter (used to indicate what character(s)
was used to replace '/' character in values contained in the URL that may contain the '/' character); default is '__'

Source:

Extends

Methods

_columnArrayParser(…columns) → {undefined|string}

Parses out column names; used by sort() and cols() methods. Not called directly.

Parameters:
Name Type Attributes Description
columns string <repeatable>

a comma delimited list of column names to parse (e.g. 'FirstName','LastName','Email')

Overrides:
Source:
Throws:
  • if no columns given, or if any column names are not strings, or are empty strings

    Type
    TypeError
  • if any column names contain spaces, or parse to numbers

    Type
    SyntaxError
Returns:
  • if one column given and value of column is false (resets sort()/cols())

    Type
    undefined
  • string of column names separated by ','

    Type
    string

_sort_asc(col) → {string}

Mark a column as ascending for sort() method. Not used in class; exposed externally as its own function in this module; note
that this method doesn't do any modifications to the column name, it's here just so developers have an explicit method

Parameters:
Name Type Description
col string

a column name to mark as descending

Overrides:
Source:
Throws:
  • if column name given is not a string

    Type
    TypeError
  • if column name given contains spaces or parses to a number

    Type
    SyntaxError
Returns:

a column name that has been marked as ascending for sort() method (effectively, no changes to input)

Type
string

_sort_desc(col) → {string}

Mark a column as descending for sort() method. Not used in class; exposed externally as its own function in this module

Parameters:
Name Type Description
col string

a column name to mark as descending

Overrides:
Source:
Throws:
  • if column name given is not a string

    Type
    TypeError
  • if column name given contains spaces or parses to a number

    Type
    SyntaxError
Returns:

a column name that has been marked as descending for sort() method

Type
string

_urlPlaceholderFn() → {string}

Sets the placeholder query string parameter; only used internally

Overrides:
Source:
Returns:

an empty string, or a query parameter string for the placeholder query parameter

Type
string

addParams(params) → {SQLPassThruFilter}

Adds SQL query parameters to this object and stores info about them

Parameters:
Name Type Description
params Object

an object of key/value pairs containing parameter names and values

Source:
Throws:
    • if params parameter is not an object
    Type
    SyntaxError
    • if any of the param keys parse to numbers
    Type
    SyntaxError
    • if any of the param keys are not strings or contain spaces
    Type
    TypeError
    • if any of the param keys contain '/' character
    Type
    TypeError
    • if any of the param values are not strings or numbers, or are empty strings
    Type
    TypeError
    • if any of the param values contain '/' character
    Type
    TypeError
Returns:

this object

Type
SQLPassThruFilter

build() → {SQLPassThruFilter}

Builds the URL endpoint string from the filter strings provided to the class and the query string parameters that have been set;
called at the end of most filter string methods and query string parameter methods

Overrides:
Source:
Returns:

this object

Type
SQLPassThruFilter

cols(…columns)

Appends the URL with set of columns to return from request

Parameters:
Name Type Attributes Description
columns string <repeatable>

a list of column names (e.g. 'FirstName','LastName','Email')

Overrides:
Source:
Returns:

this object

count(toggleopt) → {SQLPassThruFilter}

Sets the count query string parameter

Parameters:
Name Type Attributes Default Description
toggle boolean <optional>
true

sets the count query string parameter if not provided; removes the query string parameter if set to false

Source:
Returns:

this object

Type
SQLPassThruFilter

distinct(toggleopt)

Sets the distinct query string parameter

Parameters:
Name Type Attributes Default Description
toggle boolean <optional>
true

sets the parameter if not provided; removes the parameter if set to false

Overrides:
Source:
Returns:

this object

limit(numRowsopt)

Sets the limit query string parameter

Parameters:
Name Type Attributes Default Description
numRows number | boolean <optional>
false

sets the parameter with the value provided; removes the
parameter if not provided or set to false

Overrides:
Source:
Throws:

if value provided is not an integer or < 1

Type
TypeError
Returns:

this object

nullStr(nullStringopt)

Sets the nullStr query string parameter

When using the composable filter functions, if the chgPlaceHolder function is invoked to change the default
null placeholder, any BaseFilter, DataDiscoveryFilter, and SQLPassThruFilter objects created after changing
the placeholder will have the nullStr query string parameter automatically set to the value passed to chgPlaceHolder.

Parameters:
Name Type Attributes Description
nullString string <optional>

sets parameter with the value provided, resets to default if not given

Overrides:
Source:
Throws:

if value provided is not a valid string

Type
TypeError
Returns:

this object

offset(numRowsopt)

Sets the offset query string parameter

Parameters:
Name Type Attributes Default Description
numRows number | boolean <optional>
false

sets the parameter with the value provided; removes the
parameter if not provided or set to false

Overrides:
Source:
Throws:

if value provided is not an integer or < 1

Type
TypeError
Returns:

this object

sort(…columns)

Set the sort query string parameter

Parameters:
Name Type Attributes Description
columns string <repeatable>

a list of column names to sort by (e.g. 'FirstName','LastName','Email')

Overrides:
Source:
Returns:

this object

str() → {string}

Returns the URL endpoint string in this class created by build()

Overrides:
Source:
Returns:

the URL endpoint string

Type
string

transpose(toggleopt)

Sets the transpose query string parameter

Parameters:
Name Type Attributes Default Description
toggle boolean <optional>
true

sets parameter if not provided; removes the parameter if set to false

Overrides:
Source:
Returns:

this object

xmlNilVisible(toggleopt)

Sets the nil_visible query string parameter

Parameters:
Name Type Attributes Default Description
toggle boolean <optional>
true

sets the parameter if not provided; removes the parameter if set to false

Overrides:
Source:
Returns:

this object

xmlType(valopt) → {SQLPassThruFilter}

Sets the xmlType query string parameter

Parameters:
Name Type Attributes Description
val string <optional>

value for the xmlType parameter; removes the query string parameter if not provided

Source:
Throws:

if val paramter is not a string

Type
TypeError
Returns:

this object

Type
SQLPassThruFilter