/sagan

WIP - Cosmos DB driver built on rest api

Primary LanguageElixirMIT LicenseMIT

Sagan

license build Hex.pm

Azure Cosmos DB Driver for Elixir. Docs can be found at https://hexdocs.pm/sagan.

Features

  • Connects to Azure Cosmos DB through MongoDB api (wraps all functions from @ankhers mongodb driver)
  • uses poolboy pooling out of the box for all mongodb commands

Immediate Roadmap

  • Support Cosmos DB's ability to use SQL queries via REST api
  • Develop comprehensive documentation

Tentative Roadmap

  • Switch from REST to TCP. Not a lot of documentation around this so not sure if it will work.
  • Use docker image for local development and testing. Only Cosmos DB emulator available is for Windows.

Usage

Installation

If available in Hex, the package can be installed by adding sagan to your list of dependencies in mix.exs:

def deps do
  [{:sagan, "~> 0.1.2"}]
end

# in your config.exs
config :sagan,
  hostname: "host.documents.azure.com", # Azure has it listed under keys as 'https://host.documents.azure.com:443/'
  database: "your-database",
  name: :mongo, # to name the process
  username: "your-username",
  password: "your-key",
  port: 10255

Contributing

Anyone is welcome to open a pr to help with this project! All I ask that code comes with appropriate tests.

The only caveat to developing on this project right now is that there is no docker image to test against so all tests and development will need to take place against your own database. I recommend creating a database called test and a collection called testDocs that you can dump as needed. ExVcr should be cleaning your hostnames from the fixtures so if we follow this pattern, there should be no issues as more vcrs get added. Please place all new cassettes in the fixtures/custom_cassettes folder and strip out all unnecessary data from your requests. See existing cassettes for examples.