Use Multiple Predicates in Javascript

This page shows how to use two or more predicate in a single query.

Example 1

Here's an example that uses two predicates. It shows how to query all of the documents of the custom type "blog-post" with the tag "featured".

Copy
//To retreive the API object check how to query the API
api.query([
    Prismic.Predicates.at('document.type', 'blog-post'),
    Prismic.Predicates.at('document.tags', ['featured'])
]).then(function(content) {
    // content is the response object, content.results holds the documents
});

Example 2

Here's another example that queries all of the documents of the custom type "employee" excluding those with the tag "manager".

Copy
//To retreive the API object check how to query the API
api.query([
    Prismic.Predicates.at('document.type', 'employee'),
    Prismic.Predicates.not('document.tags', ['manager'])
]).then(function(employees) {
    // employees is the response object, employees.results holds the documents
});