Client

Provides a connection for memgraph.

Constructors

this
this(Client other)

Create a copy of other client.

this
this(mg_session* session)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

begin
bool begin()

Start a transaction. Return: true when the transaction was successfully started, false otherwise.

commit
bool commit()

Commit current transaction. Return: true when the transaction was successfully committed, false otherwise.

execute
Result execute(string statement)

Executes the given Cypher statement. Return: Result that can be used as a range e.g. using foreach() to process all results. After executing the statement, the method is blocked until all incoming data (execution results) are handled, i.e. until the returned Result has been completely processed.

execute
Result execute(string statement, Map params)

Executes the given Cypher statement, supplied with additional params. Return: Result that can be used as a range e.g. using foreach() to process all results. After executing the statement, the method is blocked until all incoming data (execution results) are handled, i.e. until the returned Result has been completely processed.

opAssign
Client opAssign(Client rhs)

Assigns a client to another. The target of the assignment gets detached from whatever client it was attached to, and attaches itself to the new client.

opCast
auto opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
rollback
bool rollback()

Rollback current transaction. Return: true when the transaction was successfully rolled back, false otherwise.

run
bool run(string statement)

Runs the given Cypher statement and discards any possible results. Return: true when the statement ran successfully, false otherwise.

Properties

error
auto error [@property getter]

Obtains the error message stored in the current session (if any).

status
auto status [@property getter]

Returns the status of the current session. Return: One of the session codes in mg_session_code.

Static functions

clientVersion
auto clientVersion()

Client software version. Return: Client version in the major.minor.patch format.

connect
Client connect()

Static method that creates a Memgraph client instance using default parameters localhost:7687 Return: client connection instance. Returns an unconnected instance if the connection couldn't be established.

connect
Client connect(Params params)

Static method that creates a Memgraph client instance. Return: client connection instance. If the connection couldn't be established given the params, it will return an unconnected instance.

Examples

Connect example

import std.stdio;
import memgraph;
// Connect to memgraph DB at localhost:7688
Params p = { host: "localhost", port: 7688 };
auto client = Client.connect(p);
if (!client) writefln("cannot connect to %s:%s: %s", p.host, p.port, client.status);

Meta