High level answer: you call signin
from whichever client library you are using, at the moment most of this is still in development, e.g. see https://github.com/surrealdb/surrealdb.js
Low level answer, there are multiple types of logins, the regular root login requires user
and pass
. For a scope login, you specify NS
, DB
, and SC
values, for namespace, database and scope respectively, then you add any values needed for the scope.
You can connect to a websocket at ws://<host>:<port>/rpc
, then send commands as json in the format
{
"id": <an id so you can identify responses later on>,
"method": <one of the available commands>,
"params": <an array of parameters>
}
As a minimal example, lets create some commands to signin to the scope you defined:
method params
------ ------
signin {
"NS": <ns>,
"DB": <DB>,
"SC": "admin",
// these parameters can be anything you request in the scope
"user": <user>,
"pass": <pass>
}
use <namespace>, <database>
// use your session ...