API Notes

This page is a framework for assessing how well Neo4j fits the Ecto APIs. Basically, it walks through the Ecto APIs, concentrating on problematic issues. Much of the material is lifted from the Ecto documentation; go there for the definitive word!

Ecto.Adapters.Connection

Behaviour for adapters that rely on connections.

In order to use a connection, adapter developers need to implement a single callback in a module: connect/1 defined in this module.

The benefit of implementing this module is that the adapter can then be used with all the different pools provided by Ecto.

The Ecto.Adapters.Connection behaviour has two functions and one callback.

Functions

  • connect(module, opts)
    Executes the connect in the given module, ensuring the repository's after_connect/1 is invoked in the process

    Status: no problems expected

  • shutdown(pid, shutdown \\ 5000)
    Shutdown the given connection pid

    Status: no problems expected

Callbacks

  • connect(arg0)
    Connects to the underlying database

    Status: no problems expected

Ecto.Adapters.SQL

Behaviour and implementation for SQL adapters.

The implementation for SQL adapter provides a pool-based implementation of SQL and also exposes a query function to developers.

Developers that use Ecto.Adapters.SQL should implement a connection module with specifics on how to connect to the database and also how to translate the queries to SQL.

The Ecto.Adapters.SQL module has six functions.

Functions

  • begin_test_transaction(repo, opts \\ [])
    Starts a transaction for test

    Status: no problems expected

  • query(repo, sql, params, opts \\ [])
    Runs custom SQL query on given repo

    Status: no problems expected, Cypher differences aside

  • query!(repo, sql, params, opts \\ [])
    Same as query/4 but raises on invalid queries

    Status: no problems expected, Cypher differences aside

  • restart_test_transaction(repo, opts \\ [])
    Restarts a test transaction, see begin_test_transaction/2

    Status: no problems expected

  • rollback_test_transaction(repo, opts \\ [])

  • to_sql(kind, repo, queryable)
    Converts the given query to SQL according to its kind and the adapter in the given repository

    Status: no problems expected, Cypher differences aside

Ecto.Adapters.SQL.Query

Specifies the behaviour to be implemented by the connection for handling all SQL queries.

The Ecto.Adapters.SQL.Query module has one type and 14 callbacks.

Types

  • result()

    Status: no problems expected

Callbacks

  • all(arg0)
    Receives a query and must return a SELECT query

    Status: no problems expected

  • begin_transaction()
    Command to begin transaction

    Status: no problems expected

  • commit()
    Command to commit transaction

    Status: no problems expected

  • delete(prefix, table, filters, returning)
    Returns a DELETE for the filters, returning the given returning

    Status: no problems expected

  • delete_all(arg0)
    Receives a query and must return a DELETE query

    Status: no problems expected, Cypher differences aside

  • execute_ddl(arg0)
    Receives a data definition language (DDL) command and returns a query that executes it

    Status: no problems expected, Cypher differences aside

  • insert(prefix, table, fields, returning)
    Returns an INSERT for the given fields in table, returning the given returning

    Status: no problems expected, Cypher differences aside

  • query(pid, query, params, opts)
    Executes the given query with params in connection

    Status: no problems expected

  • rollback()
    Command to rollback transaction

    Status: no problems expected

  • rollback_to_savepoint(savepoint)
    Command to rollback to savepoint

    Status: does Neo4j have savepoints?

  • savepoint(savepoint)
    Command to emit savepoint

    Status: does Neo4j have savepoints?

  • to_constraints(arg0)
    Receives the exception returned by query/4

    Status: no problems expected

  • update(prefix, table, fields, filters, returning)
    Returns an UPDATE for the given fields in table, filtered by filters returning the given returning

    Status: no problems expected, Cypher differences aside

  • update_all(arg0)
    Receives a query and values to update and must return an UPDATE query

    Status: no problems expected, Cypher differences aside

Ecto.Adapters.SQL.Sandbox

Start a pool with a single sandboxed SQL connection.

The Ecto.Adapters.SQL.Sandbox module has two functions.

Functions

  • handle_query(query, log, opts, s)

    Status: no problems expected

  • start_link(conn_mod, opts)
    Starts a pool with a single sandboxed connections for the given SQL connection module and options

    Status: no problems expected


This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r5 - 04 Apr 2016, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email