Class: Predications

Predications

A fluent interace for creating queries against resourceful endpoints

It is not intended that this class will be used on its own by end users. Instead, require it from Query as in the below example.


new Predications(field)

Parameters:
Name Type Description
field string

The field name to set criteria against

Source:
Example
import { where, field } from '@pikselpalette/sequoia-js-client-sdk/lib/query';

where(field('title').notEqualTo('foo')).and(field("startedAt").lessThan("2014"))

Methods


between(start, end)

Generates a url encoded criteria expression equivalent to: field=start/end

Parameters:
Name Type Description
start string | number

start value for this predicate

end string | number

end value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').between('2014', '2015'); // returns 'startedAt=2014/2015'

equalTo(value)

Generates a url encoded criteria expression equivalent to: field=value

Parameters:
Name Type Description
value string

value for this predicate

Source:
Returns:
Type
string
Example
field('engine').equalTo('diesel'); // returns 'engine=diesel'

exists()

Generates a url encoded criteria expression equivalent to: field=*

Source:
Returns:
Type
string
Example
field('engine').exists(); // returns 'engine=*'

greaterThan(value)

Generates a url encoded criteria expression equivalent to: field=!/value

Parameters:
Name Type Description
value string | number

value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').greaterThan(2015); // returns 'startedAt=!/2015'

greaterThanOrEqualTo(value)

Generates a url encoded criteria expression equivalent to: field=value/

Parameters:
Name Type Description
value string | number

value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').greaterThanOrEqualTo(2015); // returns 'startedAt=2015/'

lessThan(value)

Generates a url encoded criteria expression equivalent to: field=!value/

Parameters:
Name Type Description
value string | number

value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').lessThan(2015); // returns 'engine=!2015/'

lessThanOrEqualTo(value)

Generates a url encoded criteria expression equivalent to: field=/value

Parameters:
Name Type Description
value string | number

value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').lessThanOrEqualTo(2015); // returns 'startedAt=/2015'

notBetween(start, end)

Generates a url encoded criteria expression equivalent to: field=!start/end

Parameters:
Name Type Description
start string | number

start value for this predicate

end string | number

end value for this predicate

Source:
Returns:
Type
string
Example
field('startedAt').notBetween('2014', '2015'); // returns 'startedAt=!2014/2015'

notEqualTo(value)

Generates a url encoded criteria expression equivalent to: field=!value

Parameters:
Name Type Description
value string

value for this predicate

Source:
Returns:
Type
string
Example
field('engine').notEqualTo('diesel'); // returns 'engine=!diesel'

notExists()

Generates a url encoded criteria expression equivalent to: field=!*

Source:
Returns:
Type
string
Example
field('engine').notExists(); // returns 'engine=!*'

oneOrMoreOf(value)

Generates a url encoded criteria expression equivalent to: field=value1||value2

Parameters:
Name Type Argument Description
value string <repeatable>

value(s) for this predicate

Source:
Returns:
Type
string
Example
field('engine').oneOrMoreOf('diesel', 'petrol'); // returns 'engine=diesel||petrol'

startsWith(value)

Generates a url encoded criteria expression equivalent to: field=value*

Parameters:
Name Type Description
value string

value for this predicate

Source:
Returns:
Type
string
Example
field('engine').startsWith('diesel'); // returns 'engine=diesel*'