Class: DataDiscoveryFilter

DataDiscoveryFilter(filteropt, wildcardopt, separatoropt, urlPlaceholderopt)

Class for creating URL strings for SlashDB Data Discovery functionality

Constructor

new DataDiscoveryFilter(filteropt, wildcardopt, separatoropt, urlPlaceholderopt)

Create a DataDiscoveryFilter object for making SlashDB-compatible URL strings

Parameters:
Name Type Attributes Default Description
filter string <optional>
null

optional filter string to instantiate object with; accepts strings created using filter expression functions

wildcard string <optional>
*

set if using a special wildcard character(s) in URL strings (default is *)

separator string <optional>
,

set if using a special separator character(s) in URL strings (default is ,)

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:
Throws:
  • if wildcard or separator parameters are not strings, are empty strings, or contain '/' character

    Type
    TypeError
  • if filter parameter is not a string or an empty string

    Type
    TypeError
  • if filter parameter does not contain '/' character

    Type
    SyntaxError

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

addFilter(filterString) → {DataDiscoveryFilter}

Add a filter string to this object and stores info about filter; accepts strings created using filter expression functions

Parameters:
Name Type Description
filterString string

a filter string; can contain multiple filters (e.g. 'FirstName/Tim/LastName/Smith') or values
created using filter expression functions

e.g. and(eq('FirstName','Tim'),eq('LastName','Smith'))

Source:
Throws:
    • if filterString parameter is not a string or is an empty string
    Type
    TypeError
    • if filterString parameter does not contain '/' character
    Type
    SyntaxError
Returns:

this object

Type
DataDiscoveryFilter

build() → {DataDiscoveryFilter}

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
DataDiscoveryFilter

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

csvHeader(toggleopt) → {DataDiscoveryFilter}

Sets the headers query string parameter; applies only to CSV formatted data

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

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

Source:
Returns:

this object

Type
DataDiscoveryFilter

csvNullStr(toggleopt) → {DataDiscoveryFilter}

Sets the csvNullStr query string parameter; applies only to CSV formatted data

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

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

Source:
Returns:

this object

Type
DataDiscoveryFilter

depth(levelopt) → {DataDiscoveryFilter}

Sets the depth query string parameter

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

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

Source:
Throws:

if value provided is not an integer or < 1

Type
TypeError
Returns:

this object

Type
DataDiscoveryFilter

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

join(resource) → {DataDiscoveryFilter}

Adds a resource to this object and stores info about it

Parameters:
Name Type Description
resource string

resource name to add to object

Source:
Throws:
    • if resource parameter is not a string or is an empty string
    Type
    TypeError
    • if resource parameter contains '/' character
    Type
    SyntaxError
    • if resource parameter parses to a number or contains a space
    Type
    SyntaxError
Returns:

this object

Type
DataDiscoveryFilter

jsonHref(toggleopt) → {DataDiscoveryFilter}

Sets the href query string parameter; applies only to JSON/XML formatted data

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

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

Source:
Returns:

this object

Type
DataDiscoveryFilter

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

stream(toggleopt) → {DataDiscoveryFilter}

Sets the stream 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

Source:
Returns:

this object

Type
DataDiscoveryFilter

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

wantarray(toggleopt) → {DataDiscoveryFilter}

Sets the wantarray 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

Source:
Returns:

this object

Type
DataDiscoveryFilter

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

xsdCardinality(valueopt) → {DataDiscoveryFilter}

Sets the cardinality query string parameter; applies only to XSD formatted data

Parameters:
Name Type Attributes Default Description
value string <optional>
unbounded

the value for the parameter (default is 'unbounded'); removes the parameter if set to false

Source:
Throws:
  • if value parameter is an empty string

    Type
    TypeError
  • if value parameter is not an integer or < 0

    Type
    TypeError
Returns:

this object

Type
DataDiscoveryFilter