ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - YgorCastor/ravix-ecto: An Ecto adapter for the Ravix RavenDB Driver
An Ecto adapter for the Ravix RavenDB Driver. Contribute to YgorCastor/ravix-ecto development by creating an account on GitHub.
Visit Site

GitHub - YgorCastor/ravix-ecto: An Ecto adapter for the Ravix RavenDB Driver

GitHub - YgorCastor/ravix-ecto: An Ecto adapter for the Ravix RavenDB Driver

Ravix Ecto

Build & Tests

RavenDB is an amazing multi-model NoSQL database, and albeit it does not support SQL, its RQL Language if pretty close, so behold, now you can query it like a simple Ecto-SQL database.

This adapter leverages the use of Ravix as a driver between ecto and RavenDB

Installing

Add Ravix Ecto to your mix.exs dependencies

{:ravix_ecto, "~> 0.4.0"}

Example

# In your config/config.exs file
config :my_app, Store,
  urls: [System.get_env("RAVENDB_URL", "http://localhost:8080")],
  database: "test",
  retry_on_failure: true,
  retry_on_stale: true,
  retry_backoff: 500,
  retry_count: 3,
  force_create_database: true,
  document_conventions: %{
    max_number_of_requests_per_session: 30,
    max_ids_to_catch: 32,
    timeout: 30,
    use_optimistic_concurrency: false,
    max_length_of_query_using_get_url: 1024 + 512,
    identity_parts_separator: "/",
    disable_topology_update: false
  }

config :my_app, Repo, store: Store

# In your application code
defmodule Store do
  use Ravix.Documents.Store, otp_app: :my_app
end

defmodule Repo do
  use Ecto.Repo,
    otp_app: :ravix_ecto,
    adapter: Ravix.Ecto.Adapter
end

defmodule TestApplication do
  use Application

  def start(_opts, _) do
    children = [
      {Repo, [%{}]}
    ]

    Supervisor.init(
      children,
      strategy: :one_for_one
    )
  end
end

defmodule Weather do
  use Ecto.Model

  @primary_key {:id, :binary_id, autogenerate: true}
  schema "weather" do
    field :city     # Defaults to type :string
    field :temp_lo, :integer
    field :temp_hi, :integer
    field :prcp,    :float, default: 0.0
  end
end

defmodule Simple do
  import Ecto.Query

  def sample_query do
    query = from w in Weather,
          where: w.prcp > 0 or is_nil(w.prcp),
         select: w
    Repo.all(query)
  end
end

Caveats

RavenDB does not support integer ids

In RavenDB all the IDs are strings, so the :id type will generate a non-integer type

Aggregations on RavenDB are different

In RavenDB the aggregations use a Map-Reduce index based aggregation, which gets a bit annoying to deal using Ecto, so for now, you can only do aggregations using Ravix Directly.

Conflicts management

RavenDB deals a bit different with conflicts, so right now if you have a conflict, an exception will be raised. Ecto strategies are not supported yet.

Associations

RavenDB is a Document-Database first, it does support a kind of documents association, but i've not implemented it yet (mostly because i think relationships in documents sucks). You can however use embed schemas normally.

Migrations

RavenDB is schemaless, so migrations are kind of useless. We can however use it to setup indexes and so on, but it's not implemented yet.

TODOs

  • Aggregations
  • Conflict Management
  • Associations

Contributors

mongodb_ecto - From who i shamelessly forked and adapted this driver, that saved me a lot of work : D

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory