Ecto integration for Apache Cassandra.
Documentation: http://hexdocs.pm/cassandra_ecto/
- Migrations (with UDT, UDF, UDA and materialized views support)
- Lightweight transactions
- Batching (only for
insert_all
queries) - Streaming
# In your config/config.exs file
config :my_app, Repo,
keyspace: "my_keyspace"
# In your application code
defmodule Repo do
use Ecto.Repo,
otp_app: :my_app,
adapter: Cassandra.Ecto
end
defmodule Post do
use Ecto.Schema
@primary_key {:id, :binary_id, autogenerate: true}
schema "posts" do
field :title, :string
field :text, :string
field :tags, {:array, :string}
timestamps()
end
end
defmodule Simple do
import Ecto.Query
def sample_query do
query = from p in Post, where: "elixir" in p.tags
Repo.all(query, allow_filtering: true)
end
end
Tested against 3.7+.
- Add
cassandra_ecto
andcqerl
to your list of dependencies inmix.exs
:
```elixir
def deps do
[{:cqerl, github: "matehat/cqerl", tag: "v1.0.2", only: :test},
{:cassandra_ecto, "~> 0.4.0"}]
end
```
- Ensure
cassandra_ecto
andcqerl
is started before your application:
```elixir
def application do
[applications: [:cassandra_ecto, :cqerl]]
end
```
To contribute you need to compile cassandra_ecto
from source and test it:
$ git clone https://github.com/vintikzzz/cassandra_ecto.git
$ cd cassandra_ecto
$ mix deps.get
$ mix espec
Copyright 2016 Pavel Tatarskiy
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.