• Start

Methods

signin

The signin() method for the SurrealDB Mojo SDK signs in to the database with credentials.

Signs in to the database with CBOR-encoded credentials. On success, the returned token is stored on the client for subsequent requests.

Method Syntax
client.signin(credentials_cbor, session)

Argument

Description

credentials_cbor

The credentials, CBOR-encoded as a map, as a

List[UInt8]

.

session

An optional session id.

from surrealdb import CborCodec
from std.collections import List

var codec = CborCodec()
var pairs = List[Tuple[String, List[UInt8]]]()
pairs.append(Tuple(String("user"), codec.encode_text("root")))
pairs.append(Tuple(String("pass"), codec.encode_text("root")))

var resp = client.signin(codec.encode_map(pairs))
Note

signin operates on a stateful session, which is provided by the WebSocket transport. WebSocket support is rolling out. Over HTTP, supply credentials with the access_token field on ConnectOptions.

Was this page helpful?