# Queries

Queries allow you to retrieve entries using something other than their byname, i.e. key.

# Defining A Query

DashKite DB currently supports exemplar queries, which return results that match the properties and values of the query. For example, to query the films collection for films released in 1977 whose genre is science fiction, our exemplar query would specify the year property as 1977 and the genre property as sci-fi.

The DB HTTP API uses query parameters to specify queries for a given collection. For the example above, the curl command would look something like this:

curl -XGET "https://db.dashkite.io/db/${DASHKITE_DB}/collections/films/entry?year=1977&genre=sci-fi" \
    -H"Authorization:${DASHKITE_API_KEY}"

The query itself looks like this:

year=1977&genre=sci-fi

If we break that up a little to make it easier to read, we have:

year = 1977 & genre = sci-fi

Generally, the query is a list of constrains separated by &. In turn, each constraint takes the form property = value.

# Querying A Collection

# Querying A Single Entry

curl -XGET "https://db.dashkite.io/db/{db}/collections/{collection}/entry?{query}" \
    -H "Authorization: {api-key}" \
    -H'Accept: application/json'
Parameter Description
db The database address. You can get the database address from the Web app or from the API response when you create the database.
collection The collection byname.
query The query parameters for the query to run. See Defining A Query.
api-key Your API key, which allows you to access your databases. You can get your API key from the Web application.

This feature is not yet available in the Web app.

# Querying Multiple Entries

To return a list of matching entries instead of a single match, we simply change entry to entries:

curl -XGET "https://db.dashkite.io/db/{db}/collections/{collection}/entries?{query}" \
    -H "Authorization: {api-key}" \
    -H'Accept: application/json'

See Querying A Single Entry.

This feature is not yet available in the Web app.

# Querying With Metadata

You may include metadata in a query by adding +metadata to the path.

# Example

curl -XGET "https://db.dashkite.io/db/{db}/collections/{collection}/entries+metadata?{query}" \
    -H "Authorization: {api-key}" \
    -H 'Accept: application/json'

See Querying A Single Entry and Querying Multiple Entries.

This feature is not yet available in the Web app.