Namespace: Predicates

Predicates

Methods

(static) any(fragment, values) → {Array}

Build an "any" predicate: equality of a fragment to a value.
Parameters:
Name Type Description
fragment String
values Array
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.any("document.type", ["article", "blog-post"])

(static) at(fragment, value) → {Array}

Build an "at" predicate: equality of a fragment to a value.
Parameters:
Name Type Description
fragment String
value String
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.at("document.type", "article")

(static) dateAfter(fragment, after) → {Array}

Build a "date.after" predicate: documents where the fragment field is after the given date.
Parameters:
Name Type Description
fragment String the name of the field - must be a date or timestamp field.
after Date
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.dateAfter("my.product.releaseDate", new Date(2014, 1, 1))

(static) dateBefore(fragment, before) → {Array}

Build a "date.before" predicate: documents where the fragment field is before the given date.
Parameters:
Name Type Description
fragment String the name of the field - must be a date or timestamp field.
before Date
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.dateBefore("my.product.releaseDate", new Date(2014, 6, 1))

(static) dateBetween(fragment, before, after) → {Array}

Build a "date.between" predicate: combination of dateBefore and dateAfter
Parameters:
Name Type Description
fragment String the name of the field - must be a date or timestamp field.
before Date
after Date
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.dateBetween("my.product.releaseDate", new Date(2014, 1, 1), new Date(2014, 6, 1))

(static) dayOfMonth(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number between 1 and 31
Source:
Returns:
Type
Array
Example
Predicates.dayOfMonth("my.product.releaseDate", 14)

(static) dayOfMonthAfter(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number between 1 and 31
Source:
Returns:
Type
Array
Example
Predicates.dayOfMonthAfter("my.product.releaseDate", 14)

(static) dayOfMonthBefore(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number between 1 and 31
Source:
Returns:
Type
Array
Example
Predicates.dayOfMonthBefore("my.product.releaseDate", 14)

(static) dayOfWeek(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number | String Number between 1 and 7 or string between "Monday" and "Sunday"
Source:
Returns:
Type
Array
Example
Predicates.dayOfWeek("my.product.releaseDate", 14)

(static) dayOfWeekAfter(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number | String Number between 1 and 7 or string between "Monday" and "Sunday"
Source:
Returns:
Type
Array
Example
Predicates.dayOfWeekAfter("my.product.releaseDate", "Wednesday")

(static) dayOfWeekBefore(fragment, day) → {Array}

Parameters:
Name Type Description
fragment
day Number | String Number between 1 and 7 or string between "Monday" and "Sunday"
Source:
Returns:
Type
Array
Example
Predicates.dayOfWeekBefore("my.product.releaseDate", "Wednesday")

(static) fulltext(fragment, value) → {Array}

Build a "fulltext" predicate: fulltext search in a fragment.
Parameters:
Name Type Description
fragment String
value String the term to search
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.fulltext("my.article.body", "sausage"])

(static) gt(fragment, value) → {Array}

Build a "number.gt" predicate: documents where the fragment field is greater than the given value.
Parameters:
Name Type Description
fragment String the name of the field - must be a number.
value Number the lower bound of the predicate
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.gt("my.product.price", 10)

(static) has(fragment) → {Array}

Build a "has" predicate: documents where the requested field is defined
Parameters:
Name Type Description
fragment String
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.has("my.blog-post.author")

(static) hour(fragment, hour) → {Array}

Parameters:
Name Type Description
fragment
hour Number
Source:
Returns:
Type
Array
Example
Predicates.hour("my.product.releaseDate", 12)

(static) hourAfter(fragment, hour) → {Array}

Parameters:
Name Type Description
fragment
hour Number
Source:
Returns:
Type
Array
Example
Predicates.hourAfter("my.product.releaseDate", 12)

(static) hourBefore(fragment, hour) → {Array}

Parameters:
Name Type Description
fragment
hour Number
Source:
Returns:
Type
Array
Example
Predicates.hourBefore("my.product.releaseDate", 12)

(static) in(fragment, values) → {Array}

Build an "in" predicate: equality of a fragment to a value.
Parameters:
Name Type Description
fragment String
values Array
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.in("my.product.price", [4, 5])

(static) inRange(fragment, before, after) → {Array}

Build a "number.inRange" predicate: combination of lt and gt.
Parameters:
Name Type Description
fragment String the name of the field - must be a number.
before Number
after Number
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.inRange("my.product.price", 10, 20)

(static) lt(fragment, value) → {Array}

Build a "number.lt" predicate: documents where the fragment field is lower than the given value.
Parameters:
Name Type Description
fragment String the name of the field - must be a number.
value Number the upper bound of the predicate
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.lt("my.product.price", 20)

(static) missing(fragment) → {Array}

Build a "missing" predicate: documents where the requested field is empty
Parameters:
Name Type Description
fragment String
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.missing("my.blog-post.author")

(static) month(fragment, month) → {Array}

Parameters:
Name Type Description
fragment
month Number | String Number between 1 and 12 or string between "January" and "December"
Source:
Returns:
Type
Array
Example
Predicates.month("my.product.releaseDate", "June")

(static) monthAfter(fragment, month) → {Array|Array}

Parameters:
Name Type Description
fragment
month Number | String Number between 1 and 12 or string between "January" and "December"
Source:
Returns:
  • Type
    Array
  • Type
    Array
Example
Predicates.monthAfter("my.product.releaseDate", "June")

(static) monthBefore(fragment, month) → {Array}

Parameters:
Name Type Description
fragment
month Number | String Number between 1 and 12 or string between "January" and "December"
Source:
Returns:
Type
Array
Example
Predicates.monthBefore("my.product.releaseDate", "June")

(static) near(fragment, latitude, longitude, radius) → {Array}

Parameters:
Name Type Description
fragment
latitude Number
longitude Number
radius Number in kilometers
Source:
Returns:
Type
Array
Example
Predicates.near("my.store.location", 48.8768767, 2.3338802, 10)

(static) not(fragment, value) → {Array}

Build an "not" predicate: inequality of a fragment to a value.
Parameters:
Name Type Description
fragment String
value String
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.not("document.type", "article")

(static) similar(documentId, maxResults) → {Array}

Build a "similar" predicate.
Parameters:
Name Type Description
documentId String the document id to retrieve similar documents to.
maxResults Number the maximum number of results to return
Source:
Returns:
an array corresponding to the predicate
Type
Array
Example
Predicates.similar("UXasdFwe42D", 10)

(static) toQuery()

Convert a predicate (array of 3 elements) into a query for prismic.io (string)
Source:

(static) year(fragment, year) → {Array}

Parameters:
Name Type Description
fragment
year Number
Source:
Returns:
Type
Array
Example
Predicates.year("my.product.releaseDate", 2014)