Query by Type

All of the documents of the custom type “blog-post” sorted by their date (from most recent to the oldest)

Copy
      api.query(
    Prismic.Predicates.at('document.type', 'blog-post'),
    { orderings : '[my.blog-post.date desc]' }
).then(function(blogPosts) {
    // blogPosts is the response object, blogPosts.results holds the documents
});
    
Copy
      $blogPosts = $api->query(
    Predicates::at('document.type', 'blog-post'),
    [ 'orderings' => '[my.blog-post.date desc]' ]
);
// $blogPosts is the response object, $blogPosts->getResults() holds the documents
    
Copy
      blog_posts = api.query(
    Prismic::Predicates.at("document.type", "blog-post"),
    { "orderings" => "[my.blog-post.date desc]" }
)
# blog_posts is the response object, blog_posts.results holds the documents
    

All of the documents of the custom type “video-game” sorted alphabetically, limited to 10 games per page, showing the second page of results.

Copy
      api.query(
    Prismic.Predicates.at('document.type', 'video-game'),
    { pageSize : 10, page : 2, orderings : '[my.video-game.title]' }
).then(function(games) {
    // games is the response object, games.results holds the documents
});
    
Copy
      $games = $api->query(
    Predicates::at('document.type', 'video-game'),
    [ 'pageSize' => 10, 'page' => 2, 'orderings' => '[my.video-game.title]' ]
);
// $games is the response object, $games->getResults() holds the documents
    
Copy
      games = api.query(
    Prismic::Predicates.at("document.type", "video-game"),
    { "pageSize" => 10, "page" => 2, "orderings" => "[my.video-game.title]" }
)
# games is the response object, games.results holds the documents