Cassandra Ecto Adapter
Switch branches/tags
Clone or download
alirajabi Bump to 1.0.2
Disable cache every query by default
Update cassandra driver to fix major bugs
Latest commit a96afa1 Nov 3, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib Disable cache every query on ets Oct 28, 2018
test Fix and support IPv6 (#20) Oct 24, 2017
.gitignore Update git ignore Oct 28, 2018
.travis.yml Fix travis-ci Oct 20, 2017
LICENSE.md Add package info and update README Oct 9, 2016
README.md Fixed a typo in readme May 31, 2017
mix.exs Bump to 1.0.2 Nov 3, 2018
mix.lock Bump to 1.0.2 Nov 3, 2018

README.md

EctoCassandra

Build Status Hex.pm Hex.pm Coverage Status

Cassandra Adapter for Ecto (the language integrated query for Elixir)

Example

# In your config/config.exs file
config :my_app, ecto_repos: [Sample.Repo]

config :my_app, Sample.Repo,
  adapter: EctoCassandra.Adapter,
  keyspace: "ecto_simple",
  contact_points: ["localhost"],
  replication: [
    class: "SimpleStrategy",
    replication_factor: 1,
  ]

# In your application code
defmodule Sample.Repo.Migrations.CreateUser do
  use Ecto.Migration

  def change do
    create table(:users, primary_key: false) do
      add :id, :id, partition_key: true
      add :age, :integer, clustering_column: true
      add :name, :string
      add :email, :string
      add :password_hash, :string

      timestamps()
    end
  end
end

defmodule Sample.Repo do
  use Ecto.Repo, otp_app: :my_app
end

defmodule Sample.User do
  use Ecto.Schema

  @primary_key false
  schema "users" do
    field :username, primary_key: true
    field :age, :integer
    field :name # Defaults to type :string
    field :email
    field :password_hash
    field :password, :string, virtual: true
  end
end

defmodule Sample.App do
  import Ecto.Query
  alias Sample.{Repo, User}

  def keyword_query do
    Repo.all from u in User,
      where: u.username == "john",
      select: u.email
  end

  def pipe_query do
    User
    |> where([u], u.age > 10)
    |> order_by(:age)
    |> limit(10)
    |> Repo.all
  end

  def get_by_name do
    Repo.get_by(username: "john")
  end
end