Ecto.Adapters.SQL.Connection
Ecto.Adapters.SQL.Connection behaviour
Specifies the behaviour to be implemented by all SQL connections.
Summary
Types
- cached()
-
The cache query which is a DBConnection Query
- prepared()
-
The prepared query which is an SQL command
Callbacks
- all(query)
-
Receives a query and must return a SELECT query
- child_spec(options)
-
Receives options and returns
DBConnection
supervisor child specification - delete(prefix, table, filters, returning)
-
Returns a DELETE for the
filters
returning the givenreturning
- delete_all(query)
-
Receives a query and must return a DELETE query
- execute(connection, prepared_query, params, options)
- execute_ddl(command)
-
Receives a DDL command and returns a query that executes it
- insert(prefix, table, header, rows, on_conflict, returning)
-
Returns an INSERT for the given
rows
intable
returning the givenreturning
- prepare_execute(connection, name, prepared, params, options)
-
Prepares and executes the given query with
DBConnection
- stream(connection, prepared_query, params, options)
-
Returns a stream that prepares and executes the given query with
DBConnection
- to_constraints(exception)
-
Receives the exception returned by
query/4
- update(prefix, table, fields, filters, returning)
-
Returns an UPDATE for the given
fields
intable
filtered byfilters
returning the givenreturning
- update_all(query)
-
Receives a query and values to update and must return an UPDATE query
Types
cached()
cached() :: map
The cache query which is a DBConnection Query
prepared()
prepared() :: String.t
The prepared query which is an SQL command
Callbacks
all(query)
all(query :: Ecto.Query.t) :: String.t
Receives a query and must return a SELECT query.
child_spec(options)
child_spec(options :: Keyword.t) :: {module, Keyword.t}
Receives options and returns DBConnection
supervisor child specification.
delete(prefix, table, filters, returning)
delete(prefix :: String.t, table :: String.t, filters :: [atom], returning :: [atom]) :: String.t
Returns a DELETE for the filters
returning the given returning
.
delete_all(query)
delete_all(query :: Ecto.Query.t) :: String.t
Receives a query and must return a DELETE query.
execute(connection, prepared_query, params, options)
execute(connection :: DBConnection.t, prepared_query :: prepared, params :: [term], options :: Keyword.t) :: {:ok, term} | {:error, Exception.t}
execute(connection :: DBConnection.t, prepared_query :: cached, params :: [term], options :: Keyword.t) :: {:ok, term} | {:error | :reset, Exception.t}
execute_ddl(command)
execute_ddl(command :: Ecto.Adapter.Migration.command) :: String.t
Receives a DDL command and returns a query that executes it.
insert(prefix, table, header, rows, on_conflict, returning)
insert(prefix :: String.t, table :: String.t, header :: [atom], rows :: [[atom | nil]], on_conflict :: Ecto.Adapter.on_conflict, returning :: [atom]) :: String.t
Returns an INSERT for the given rows
in table
returning the given returning
.
prepare_execute(connection, name, prepared, params, options)
prepare_execute(connection :: DBConnection.t, name :: String.t, prepared, params :: [term], options :: Keyword.t) :: {:ok, query :: map, term} | {:error, Exception.t}
Prepares and executes the given query with DBConnection
.
stream(connection, prepared_query, params, options)
stream(connection :: DBConnection.conn, prepared_query :: prepared, params :: [term], options :: Keyword.t) :: Enum.t
Returns a stream that prepares and executes the given query with DBConnection
.
to_constraints(exception)
to_constraints(exception :: Exception.t) :: Keyword.t
Receives the exception returned by query/4
.
The constraints are in the keyword list and must return the constraint type, like :unique
, and the constraint name as a string, for example:
[unique: "posts_title_index"]
Must return an empty list if the error does not come from any constraint.
update(prefix, table, fields, filters, returning)
update(prefix :: String.t, table :: String.t, fields :: [atom], filters :: [atom], returning :: [atom]) :: String.t
Returns an UPDATE for the given fields
in table
filtered by filters
returning the given returning
.
update_all(query)
update_all(query :: Ecto.Query.t) :: String.t
Receives a query and values to update and must return an UPDATE query.
© 2012 Plataformatec
Licensed under the Apache License, Version 2.0.
https://hexdocs.pm/ecto/Ecto.Adapters.SQL.Connection.html