Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cafebazaar/ecto-cassandra
Cassandra Ecto Adapter
https://github.com/cafebazaar/ecto-cassandra
cassandra cassandra-adapter ecto
Last synced: 9 days ago
JSON representation
Cassandra Ecto Adapter
- Host: GitHub
- URL: https://github.com/cafebazaar/ecto-cassandra
- Owner: cafebazaar
- License: other
- Created: 2016-11-07T09:22:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-03T16:56:31.000Z (about 6 years ago)
- Last Synced: 2025-01-09T20:34:09.611Z (16 days ago)
- Topics: cassandra, cassandra-adapter, ecto
- Language: Elixir
- Size: 277 KB
- Stars: 87
- Watchers: 7
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Cassandra DB Adapter for Ecto. (ORM and Datamapping)
- fucking-awesome-elixir - ecto_cassandra - Cassandra DB Adapter for Ecto. (ORM and Datamapping)
- awesome-elixir - ecto_cassandra - Cassandra DB Adapter for Ecto. (ORM and Datamapping)
README
# EctoCassandra
[![Build Status](https://travis-ci.org/cafebazaar/ecto-cassandra.svg?branch=master)](https://travis-ci.org/cafebazaar/ecto-cassandra)
[![Hex.pm](https://img.shields.io/hexpm/v/ecto_cassandra.svg?maxAge=2592000)](https://hex.pm/packages/ecto_cassandra)
[![Hex.pm](https://img.shields.io/hexpm/l/ecto_cassandra.svg?maxAge=2592000)](https://github.com/cafebazaar/ecto-cassandra/blob/master/LICENSE.md)
[![Coverage Status](https://coveralls.io/repos/github/cafebazaar/ecto-cassandra/badge.svg?branch=master)](https://coveralls.io/github/cafebazaar/ecto-cassandra?branch=master)Cassandra Adapter for [Ecto](https://github.com/elixir-ecto/ecto) (the language integrated query for Elixir)
## Example
```elixir
# 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.Migrationdef 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, :stringtimestamps()
end
end
enddefmodule Sample.Repo do
use Ecto.Repo, otp_app: :my_app
enddefmodule 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
enddefmodule 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
enddef pipe_query do
User
|> where([u], u.age > 10)
|> order_by(:age)
|> limit(10)
|> Repo.all
enddef get_by_name do
Repo.get_by(username: "john")
end
end
```