{"id":13629016,"url":"https://github.com/meppu/surreal","last_synced_at":"2025-10-01T14:31:47.647Z","repository":{"id":162726040,"uuid":"635920936","full_name":"meppu/surreal","owner":"meppu","description":"SurrealDB driver for BEAM ecosystem","archived":true,"fork":false,"pushed_at":"2023-08-30T07:09:08.000Z","size":197,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-28T13:04:11.819Z","etag":null,"topics":["driver","elixir","erlang","gleam","otp","surrealdb"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/surreal/","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meppu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-03T18:39:12.000Z","updated_at":"2024-06-27T23:53:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"39cad8ef-4c46-46e9-abd4-09c68075b1af","html_url":"https://github.com/meppu/surreal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meppu%2Fsurreal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meppu%2Fsurreal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meppu%2Fsurreal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meppu%2Fsurreal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meppu","download_url":"https://codeload.github.com/meppu/surreal/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234878308,"owners_count":18900676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","elixir","erlang","gleam","otp","surrealdb"],"created_at":"2024-08-01T22:01:01.581Z","updated_at":"2025-10-01T14:31:47.270Z","avatar_url":"https://github.com/meppu.png","language":"Erlang","funding_links":[],"categories":["Client libraries"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n   \u003cimg src=\"https://raw.githubusercontent.com/meppu/surreal/main/.github/assets/banner.webp\" alt=\"banner\" /\u003e\n\n   \u003ch2\u003eSurrealDB Erlang\u003c/h2\u003e\n   \u003cp\u003eSurrealDB driver for BEAM ecosystem\u003c/p\u003e\n\n   \u003ca href=\"https://codecov.io/gh/meppu/surreal\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://codecov.io/gh/meppu/surreal/branch/main/graph/badge.svg?token=LX33ZWN777\" alt=\"codecov\" /\u003e\n   \u003c/a\u003e\n   \u003cimg src=\"https://img.shields.io/hexpm/l/surreal\" alt=\"license\" /\u003e\n   \u003cimg src=\"https://img.shields.io/hexpm/dt/surreal\" alt=\"downloads\" /\u003e\n   \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/meppu/surreal/test.yaml?label=tests\" alt=\"tests\" /\u003e\n\n   \u003ch5\u003e⚠️ You are currently viewing version 2 ⚠️\u003c/h5\u003e\n\u003c/div\u003e\n\nSurrealDB Erlang, also referred to as \"surreal\", is a robust and maintainable SurrealDB driver for BEAM ecosystem.\n\nThe library draws inspiration from the official [surrealdb.js](https://github.com/surrealdb/surrealdb.js) implementation.\n\n## Index\n\n- [Index](#index)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n  - [Creating a Connection](#creating-a-connection)\n  - [Example Usage](#example-usage)\n  - [With Supervisor](#with-supervisor)\n  - [Additional Examples](#additional-examples)\n- [Documentation](#documentation)\n- [Contributing](#contributing)\n  - [Note for Contributors](#note-for-contributors)\n- [License](#license)\n\n## Installation\n\nSurrealDB Erlang is available on [Hex.pm](https://hex.pm/packages/surreal).\n\nAdd `surreal` to your list of dependencies in `rebar.config` file:\n\n```erlang\n{deps, [{surreal, \"2.1.0\"}]}.\n```\n\n## Getting Started\n\n### Creating a Connection\n\nYou can establish a database connection with `surreal:start_link/2` (or `surreal:start_link/3`).\n\nCheck out SurrealDB URI format described in the [documentation](https://hexdocs.pm/surreal/surreal_config.html#module-surrealdb-uri-format).\n\n```erlang\n{ok, Pid} = surreal:start_link(\"surrealdb://root:root@localhost:8000/test/test\", my_connection).\n```\n\nAlternatively, you can use the specified connection name, `my_connection`, in place of `Pid`, as shown below:\n\n```erlang\n{ok, Users} = surreal:select(my_connection, \"users\").\n```\n\n### Example Usage\n\nSurrealDB Erlang offers users a clean API, demonstrated below:\n\n```erlang\n1\u003e {ok, User} = surreal:create(Pid, \"users:meppu\", #{\u003c\u003c\"score\"\u003e\u003e =\u003e 10}).\n   % {ok,#{\u003c\u003c\"id\"\u003e\u003e =\u003e \u003c\u003c\"users:meppu\"\u003e\u003e,\u003c\u003c\"score\"\u003e\u003e =\u003e 10}}\n2\u003e {ok, NewUser} = surreal:merge(Pid, \"users:meppu\", #{\u003c\u003c\"new\"\u003e\u003e =\u003e \u003c\u003c\"key\"\u003e\u003e}).\n   % {ok,#{\u003c\u003c\"id\"\u003e\u003e =\u003e \u003c\u003c\"users:meppu\"\u003e\u003e,\u003c\u003c\"new\"\u003e\u003e =\u003e \u003c\u003c\"key\"\u003e\u003e,\n   %       \u003c\u003c\"score\"\u003e\u003e =\u003e 10}}\n3\u003e [{ok, QueryResp}] = surreal:query(Pid, \"SELECT * FROM users WHERE score = $score\", #{\u003c\u003c\"score\"\u003e\u003e =\u003e 10}).\n   % [{ok,[#{\u003c\u003c\"id\"\u003e\u003e =\u003e \u003c\u003c\"users:meppu\"\u003e\u003e,\u003c\u003c\"new\"\u003e\u003e =\u003e \u003c\u003c\"key\"\u003e\u003e,\n   %         \u003c\u003c\"score\"\u003e\u003e =\u003e 10}]}]\n4\u003e {ok, RemovedUser} = surreal:delete(Pid, \"users:meppu\").\n   % {ok,#{\u003c\u003c\"id\"\u003e\u003e =\u003e \u003c\u003c\"users:meppu\"\u003e\u003e,\u003c\u003c\"new\"\u003e\u003e =\u003e \u003c\u003c\"key\"\u003e\u003e,\n   %       \u003c\u003c\"score\"\u003e\u003e =\u003e 10}}\n5\u003e RemovedUser =:= NewUser.\n   % true\n```\n\n### With Supervisor\n\nThe recommended approach to initialise a SurrealDB connection is through a supervisor.\n\nYou can use `surreal:child_spec/1` to create a child specification for your supervisor, as shown below:\n\n```erlang\nChildSpecs = [\n    surreal:child_spec({\"surrealdb://root:root@localhost:8000/test/test\", db_conn, #{}})\n],\n```\n\n### Additional Examples\n\nSee additional examples in [examples/](https://github.com/meppu/surreal/tree/main/examples) folder.\n\n## Documentation\n\nFor detailed documentation, please refer to [HexDocs](https://hexdocs.pm/surreal).\n\n## Contributing\n\nFeel free to report bugs and request features through [GitHub Issues](https://github.com/meppu/surreal/issues).\n\nIf you wish to submit a pull request, ensure that your code is well-formatted and easily comprehensible.\n\n### Note for Contributors\n\nPlease send your pull requests to `v2` branch instead of the `main` branch.\n\nThis helps us demostrate a stable version on the `main` branch while allowing for ongoing development and improvements on the `v2` branch.\n\n## License\n\nSurrealDB Erlang is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeppu%2Fsurreal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeppu%2Fsurreal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeppu%2Fsurreal/lists"}