All Projects → elixir-mongo → mongodb_ecto

elixir-mongo / mongodb_ecto

Licence: Apache-2.0 license
MongoDB adapter for Ecto

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to mongodb ecto

Formex
A better form library for Phoenix
Stars: ✭ 206 (-40.8%)
Mutual labels:  ecto
ecto shorts
Shortcuts for ecto
Stars: ✭ 81 (-76.72%)
Mutual labels:  ecto
phoenix pagination
Simple pagination for Ecto and Phoenix that uses plain EEx templates.
Stars: ✭ 20 (-94.25%)
Mutual labels:  ecto
Ecto mnesia
Ecto adapter for Mnesia Erlang term database.
Stars: ✭ 223 (-35.92%)
Mutual labels:  ecto
fat ecto
Query mechanism for Ecto
Stars: ✭ 20 (-94.25%)
Mutual labels:  ecto
query builder
Compose Ecto queries without effort
Stars: ✭ 56 (-83.91%)
Mutual labels:  ecto
Phoenix Ecto Encryption Example
🔐 A detailed example for how to encrypt data in a Phoenix (Elixir) App before inserting into a database using Ecto Types
Stars: ✭ 166 (-52.3%)
Mutual labels:  ecto
music db
A playground for Ecto using a simple music database
Stars: ✭ 29 (-91.67%)
Mutual labels:  ecto
absinthe error payload
Bridges the gap between Ecto and Absinthe for mutation payload
Stars: ✭ 102 (-70.69%)
Mutual labels:  ecto
algoliax
Algolia integration to elixir application
Stars: ✭ 38 (-89.08%)
Mutual labels:  ecto
Etso
Ecto 3 adapter allowing use of Ecto schemas held in ETS tables
Stars: ✭ 226 (-35.06%)
Mutual labels:  ecto
ecto erd
A mix task for generating Entity Relationship Diagram from Ecto schemas available in your project.
Stars: ✭ 173 (-50.29%)
Mutual labels:  ecto
ex operation
A library for making domain operations in Elixir
Stars: ✭ 33 (-90.52%)
Mutual labels:  ecto
Ex audit
Ecto auditing library that transparently tracks changes and can revert them.
Stars: ✭ 214 (-38.51%)
Mutual labels:  ecto
querie
Compose Ecto query from the client side
Stars: ✭ 20 (-94.25%)
Mutual labels:  ecto
Rummage ecto
Search, Sort and Pagination for ecto queries
Stars: ✭ 190 (-45.4%)
Mutual labels:  ecto
prometheus-ecto
Prometheus.io collector for Elixir.Ecto
Stars: ✭ 74 (-78.74%)
Mutual labels:  ecto
ectograph
Ectograph is a set of utility functions for using Ecto in combination with graphql-elixir/graphql
Stars: ✭ 29 (-91.67%)
Mutual labels:  ecto
ecto profiler
Project for Ecto DB profiling
Stars: ✭ 16 (-95.4%)
Mutual labels:  ecto
strong migrations
Catch unsafe migrations in your Elixir application
Stars: ✭ 58 (-83.33%)
Mutual labels:  ecto

Mongo.Ecto

CI Hex.pm Module Version Hex Docs Total Download License Last Updated

Mongo.Ecto is a MongoDB adapter for Ecto.

For detailed information read the documentation for the Mongo.Ecto module, or check out examples below.

Example

# In your config/config.exs file
config :my_app, Repo,
  adapter: Mongo.Ecto,
  database: "ecto_simple",
  username: "mongodb",
  password: "mongosb",
  hostname: "localhost"

# In your application code
defmodule Repo do
  use Ecto.Repo, otp_app: :my_app
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

Usage

Add :mongodb_ecto as a dependency in your mix.exs file.

def deps do
  [
    {:mongodb_ecto, "~> 0.2"}
  ]
end

You should also update your applications to include both projects:

def application do
  [applications: [:logger, :mongodb_ecto, :ecto]]
end

To use the adapter in your repo:

defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Mongo.Ecto
end

For additional information on usage please see the documentation for Ecto.

Data Type Mapping

BSON Ecto
double :float
string  :string
object :map
array {:array, subtype}
binary data :binary
binary data (uuid) Ecto.UUID
object id :binary_id
boolean :boolean
date Ecto.DateTime
regular expression Mongo.Ecto.Regex
JavaScript Mongo.Ecto.JavaScript
symbol (see below)
32-bit integer :integer
timestamp BSON.Timestamp
64-bit integer :integer

Symbols are deprecated by the BSON specification. They will be converted to simple strings on reads. There is no possibility of persisting them to the database.

Additionally special values are translated as follows:

BSON Ecto
null nil
min key :BSON_min
max key :BSON_max

Supported Mongo versions

The adapter and the driver are tested against most recent versions from 3 branches: 2.4.x, 2.6.x, 3.0.x

Contributing

To contribute you need to compile Mongo.Ecto from source and test it:

$ git clone https://github.com/ankhers/mongodb_ecto.git
$ cd mongodb_ecto
$ mix test

Copyright and License

Copyright 2015 Michał Muskała

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 https://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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].