Skip to content

Release v0.4.0

Compare
Choose a tag to compare
@floriank floriank released this 13 Jul 12:44
cde53cd

This release contains additions to the Query DSL.

Changes

  • [#49] by @floriank adds more options to compose your queries against the CDA and CPA.

Overview

Added by/2

by/2 allows you to add collection filters as described in the API Docs to your queries against Entries and Assets.

Example

import Contentful.Query
alias Contentful.Delivery.Entries

{:ok, entries, total: 1} 
= Entries
   |> content_type("dogs")
   |> by(name: "Hasso", breed: "dalmatian")
   |> fetch_all

The filters supported here are [:in, :nin, :ne, :lte, :gte, :lt, :gt, :match, :exist]:

import Contentful.Query
alias Contentful.Delivery.Entries

{:ok, entries, total: 100}
= Entries
   |> content_type("dogs")
   |> by(name: [ne: "Hasso"], breed: "dalmatian")
   |> fetch_all

You can use any field to query, as well as the id of an entry or asset.

Added search_full_text/2

Allows the addition of a query to perform a search over all fields of an entry.

Example

{:ok, nyan_cats, total: 616} 
= Entries
   |> search_full_text("Nyancat")
   |> fetch_all