View Source Unreal (Unreal v0.2.0)

Main part of the driver. A wrapper for HTTP and WebSocket protocols.

Link to this section Summary

Functions

Modifies all records in a table.

Modifies a specific record.

Deletes all records in a table.

Deletes a specific record in a table.

Selects all records in a table.

Selects a specific record in a table.

Get info. Will do nothing for HTTP connection.

Creates a record in the database.

Creates a record in the database with id.

Invalidates the authentication for the current connection.

Assigns a value as a parameter for this connection. Only for WebSocket connection.

Applies JSON Patch changes to all records. Only works for WebSocket connection.

Modifies a specific record. Only works for WebSocket connection.

Send a ping to WebSocket connection. Will do nothing for HTTP connection.

Runs a set of SurrealQL statements against the database.

Runs a set of SurrealQL statements against the database with variables.

Signs in to a specific authentication scope.

Signs this connection up to a specific authentication scope. Only works for WebSocket connection.

Updates all records in a table.

Updates a specific record in a table.

Switch to a specific namespace and database.

Link to this section Types

Link to this section Functions

Link to this function

change(pid, table, data)

View Source
@spec change(connection(), String.t(), any()) :: result()

Modifies all records in a table.

Unreal.change(pid, "users", %{active: true})
Link to this function

change(pid, table, id, data)

View Source
@spec change(connection(), String.t(), String.t(), any()) :: result()

Modifies a specific record.

Unreal.change(pid, "users", "bob", %{active: true})
@spec child_spec(any()) :: %{id: Unreal, start: {Unreal, :start_link, [...]}}
@spec delete(connection(), String.t()) :: result()

Deletes all records in a table.

Unreal.delete(pid, "users")
@spec delete(connection(), String.t(), String.t()) :: result()

Deletes a specific record in a table.

Unreal.delete(pid, "users", "bob")
@spec get(connection(), String.t()) :: result()

Selects all records in a table.

Unreal.get(pid, "users")
@spec get(connection(), String.t(), String.t()) :: result()

Selects a specific record in a table.

Unreal.get(pid, "users", "bob")
@spec info(connection()) :: result()

Get info. Will do nothing for HTTP connection.

Unreal.info(pid)
Link to this function

insert(pid, table, data)

View Source
@spec insert(connection(), String.t(), any()) :: result()

Creates a record in the database.

Unreal.insert(pid, "users", %{key: "value"})
Link to this function

insert(pid, table, id, data)

View Source
@spec insert(connection(), String.t(), String.t(), any()) :: result()

Creates a record in the database with id.

Unreal.insert(pid, "users", "bob", %{key: "value"})
@spec invalidate(connection()) :: result()

Invalidates the authentication for the current connection.

Unreal.invalidate(pid)
@spec let(connection(), String.t(), any()) :: result()

Assigns a value as a parameter for this connection. Only for WebSocket connection.

Unreal.let(pid, "key", "value")
Link to this function

modify(pid, table, data)

View Source
@spec modify(connection(), String.t(), any()) :: result()

Applies JSON Patch changes to all records. Only works for WebSocket connection.

Unreal.modify(pid, "users", [
  { op: "replace", path: "/created_at", value: 123 },
])
Link to this function

modify(pid, table, id, data)

View Source
@spec modify(connection(), String.t(), String.t(), any()) :: result()

Modifies a specific record. Only works for WebSocket connection.

Unreal.modify(pid, "users", "bob", [
  { op: "replace", path: "/created_at", value: 123 },
])
@spec ping(connection()) :: result()

Send a ping to WebSocket connection. Will do nothing for HTTP connection.

Unreal.ping(pid)
@spec query(connection(), String.t()) :: result()

Runs a set of SurrealQL statements against the database.

Unreal.query(pid, "CREATE person; SELECT * FROM person;")
Link to this function

query(pid, command, vars)

View Source
@spec query(connection(), String.t(), map()) :: result()

Runs a set of SurrealQL statements against the database with variables.

Unreal.query(pid, "CREATE person; SELECT * FROM type::table($tb);", %{
  tb: "person"
})
@spec signin(connection(), map()) :: result()

Signs in to a specific authentication scope.

Unreal.signin(:database, %{
  NS: "test",
  DB: "test",
  SC: "user",
  email: "info@surrealdb.com",
  pass: "123456",
})

Or

Unreal.signin(:database, "root", "root")
Link to this function

signin(pid, username, password)

View Source
@spec signin(connection(), String.t(), String.t()) :: result()
@spec signup(connection(), map()) :: result()

Signs this connection up to a specific authentication scope. Only works for WebSocket connection.

Unreal.signup(:database, %{
  NS: "test",
  DB: "test",
  SC: "user",
  email: "info@surrealdb.com",
  pass: "123456",
})
@spec start_link(
  protocol: :http | :websocket,
  config: Unreal.Core.Config.t(),
  name: :atom
) ::
  :ignore | {:error, any()} | {:ok, pid()}
Link to this function

update(pid, table, data)

View Source
@spec update(connection(), String.t(), any()) :: result()

Updates all records in a table.

Unreal.update(pid, "users", %{thing: true})
Link to this function

update(pid, table, id, data)

View Source
@spec update(connection(), String.t(), String.t(), any()) :: result()

Updates a specific record in a table.

Unreal.update(pid, "users", "bob", %{thing: true})
Link to this function

use(pid, namespace, database)

View Source
@spec use(connection(), String.t(), String.t()) :: result()

Switch to a specific namespace and database.

Unreal.use(pid, "namespace", "database")