View Source eneo4j (eneo4j v1.0.0)
Link to this section Summary
Functions
Use this function to begin and commit a transaction in a single HTTP request.
Use this function to begin transaction
This function works the same as eneo4j:build_statement(Query, Params, false)
Use this function commit a transaction.
Use this function to extract information about neo4j version, distribution, etc.
Use this function to keep transaction alive. It will timeout after 60 seconds (by default).
Use this function rollback a transaction.
Use this function to begin transaction.
Link to this section Types
Specs
discovery_api_response() :: #{binary() := binary()}.
Specs
query_result() :: {ok, response()} | {error, any()}.
Specs
query_result_with_commit() :: {ok, response_with_commit()} | {error, any()}.
Specs
response() :: #{binary() := any() | [any(), ...]}.
Specs
response_with_commit() :: #{binary() := any()} | #{binary() := list()}.
Specs
statement() :: eneo4j_worker:statement().
Specs
statements() :: eneo4j_worker:statements().
Link to this section Functions
Specs
begin_and_commit_transaction(statements()) -> query_result().
Specs
begin_and_commit_transaction(statements(), timeout()) -> query_result().
Use this function to begin and commit a transaction in a single HTTP request.
Query = <<"CREATE (n:Person { name: $name, title: $title });">>,
% Provide params if needed:
ParamsAndy = #{
<<"name">> => <<"Andy">>,
<<"title">> => <<"Developer">>
},
% Build a statement:
Statement = eneo4j:build_statement(Query, ParamsAndy),
Execute the query
{ok, Result} = eneo4j:begin_and_commit_transaction([Statement], 30000).
Specs
begin_transaction(statements()) -> query_result_with_commit().
Specs
begin_transaction(statements(), timeout()) -> query_result_with_commit().
Use this function to begin transaction
QueryGetPersonsNames = <<"MATCH (n:Person) RETURN n.name">>,
Statement = eneo4j:build_statement(QueryGetPersonsNames, #{}),
{ok, Result} = eneo4j:begin_transaction([Statement]),
Specs
build_statement(binary(), #{binary() => any()}) -> statement().
This function works the same as eneo4j:build_statement(Query, Params, false)
Query = <<"MATCH (n) WHERE n.name = $name RETURN n">>,
Params = #{<<"name">> => <<"Andy">>},
Statement = eneo4j:build_statement(Query, Params),
Specs
build_statement(binary(), #{binary() => any()}, boolean()) -> statement().
Specs
commit_transaction(statements(), eneo4j_response:commit_transaction_link()) -> query_result_with_commit().
Specs
commit_transaction(statements(), eneo4j_response:commit_transaction_link(), timeout()) -> query_result_with_commit().
Use this function commit a transaction.
{ok, Response} = eneo4j:begin_transaction([Statement]),
{ok, CommitLink} = eneo4j_response:get_commit_transaction_link(Response),
% You may add statements when committing a transaction
Statements = [],
{ok, Result} = eneo4j:commit_transaction(Statements, CommitLink),
Specs
discovery_api() -> discovery_api_response().
Use this function to extract information about neo4j version, distribution, etc.
It may be used to check the connection and if the database wa configured correctly.Specs
keep_alive_transaction(eneo4j_response:run_queries_link()) -> query_result_with_commit().
Specs
keep_alive_transaction(eneo4j_response:run_queries_link(), timeout()) -> query_result_with_commit().
Use this function to keep transaction alive. It will timeout after 60 seconds (by default).
{ok, BeginResponse} = eneo4j:begin_transaction([]),
Query = <<"MATCH (n:Person) RETURN n.name">>,
Statement = eneo4j:build_statement(Query, #{}),
timer:sleep(timer:seconds(40)),
{ok, RunLink} = eneo4j_response:get_run_queries_link(BeginResponse),
{ok, RunResponse} = eneo4j:keep_alive_transaction(RunLink),
% Normally transaction would timeout here,
% but thanks to eneo4j:keep_alive_transaction/1 call it will remain opened.
timer:sleep(timer:seconds(40)),
% Run queries inside transaction many times:
{ok, RunLink2} = eneo4j_response:get_run_queries_link(RunResponse),
{ok, Result} = eneo4j:run_queries_inside_transaction([Statement], RunLink2),
Specs
rollback_transaction(eneo4j_response:rollback_transaction_link()) -> query_result_with_commit().
Specs
rollback_transaction(eneo4j_response:rollback_transaction_link(), timeout()) -> query_result_with_commit().
Use this function rollback a transaction.
{ok, Response} = eneo4j:begin_transaction([Statement]),
{ok, RollbackLink} = eneo4j_response:get_rollback_transaction_link(Response),
% You may add statements when committing a transaction
Statements = [],
{ok, Result} = eneo4j:rollback_transaction(Statements, RollbackLink),
Specs
run_queries_inside_transaction(statements(), eneo4j_response:run_queries_link()) -> query_result_with_commit().
Specs
run_queries_inside_transaction(statements(), eneo4j_response:run_queries_link(), timeout()) -> query_result_with_commit().
Use this function to begin transaction.
{ok, BeginResponse} = eneo4j:begin_transaction([]),
Query = <<"MATCH (n:Person) RETURN n.name">>,
Statement = eneo4j:build_statement(Query, #{}),
{ok, RunLink} = eneo4j_response:get_run_queries_link(BeginResponse),
{ok, RunResponse} = eneo4j:run_queries_inside_transaction([Statement], RunLink),
% Run queries inside transaction many times:
{ok, RunLink2} = eneo4j_response:get_run_queries_link(RunResponse),
{ok, Result} = eneo4j:run_queries_inside_transaction([Statement], RunLink2),