β οΈ You are currently viewing main branchβ οΈ
Package name named as surreal on hex. Because an Erlang implementation can be used in other languages that runs on BEAM virtual machine, such as Elixir and Gleam.
This library tries to be compatible with the official implementation.
Installation
Add surreal
to your list of dependencies in rebar.config
file:
{deps, [{surreal, "1.1.0"}]}.
Usage
Simple Connection
1> {ok, Pid} = surreal:start_link("ws://localhost:8000").
% {ok, <pid>}
2> surreal:signin(Pid, "root", "root").
% {ok, null}
3> surreal:use(Pid, "test", "test").
% {ok, null}
4> surreal:create(Pid, "example:bob",
4> #{<<"name">> => <<"bob">>}).
% {ok, #{<<"id">> => <<"example:bob">>, <<"name">> => <<"bob">>}},
5> surreal:query(Pid, "SELECT * FROM type::table($tb);",
5> #{<<"tb">> => <<"test">>}).
% [{ok, [#{<<"id">> => <<"example:bob">>, <<"name">> => <<"bob">>}]}]
Connect with Config
1> Config = [
1> % link the process
1> link,
1> % register local name
1> {name, example_client},
1> % host and port
1> {host, "localhost"},
1> {port, 8000},
1> % database, namespace to use
1> {use, {"test", "test"}},
1> % user, pass auth
1> {signin, {"root", "root"}}
1> ].
% ...
2> {ok, Pid} = surreal_config:load(Config).
% ...
3> surreal:create(example_client, "example:bob",
3> #{<<"name">> => <<"bob">>}).
% {ok, #{<<"id">> => <<"example:bob">>, <<"name">> => <<"bob">>}},
Documentation
Documentation is available at HexDocs.
Contributing
You can always report bugs and request features via GitHub Issues.
For pull requests, make sure your code is well-formatted and at least can explain itself.
License
SurrealDB Erlang is licensed under the MIT License.