Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md to incude a usage example #39

Merged
merged 2 commits into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ defmodule MyApp.Repo.Migrations.SetupTimescale do
end
```

## Using the Library
Here is an intermediate example querying a timescale reading using Timescale [hyperfunctions](https://docs.timescale.com/api/latest/hyperfunctions/) with `timescale`'s Ecto extensions.

For a more comprehensive example you can check out our guide in the docs [here](https://hexdocs.pm/timescale/intro.html#content).

```elixir
import Timescale.Hyperfunctions

Repo.all(
from(h in "heartbeats",
where: h.user_id == ^alex_id,
group_by: selected_as(:minute),
select: %{
minute: selected_as(time_bucket(h.timestamp, "1 minute"), :minute),
bpm: count(h)
},
limit: 5
)
)
```

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
Expand Down