SurrealDB Docs Logo

Enter a search query

SDK methods

The JavaScript SDK comes with a number of built-in functions.

FunctionDescription
async db.connect(url, options)Connects to a local or remote database endpoint
async db.wait()Waits for the connection to the database to succeed
async db.close()Closes the persistent connection to the database
async db.use(namespace,database)Switch to a specific namespace and database
async db.info<T>()Returns the record of an authenticated scope user
async db.signup(vars)Signs this connection up to a specific authentication scope
async db.signin(vars)Signs this connection in to a specific authentication scope
async db.invalidate()Invalidates the authentication for the current connection
async db.authenticate(token)Authenticates the current connection with a JWT token
async db.let(key,val)Assigns a value as a parameter for this connection
async db.unset(key)Removes a parameter for this connection
async db.live<T>(tabel, callback,diff)Initiate a live query
async db.subscribeLive<T>(queryUuid,callback)Register a callback for a running live query
async db.kill(queryUuid)Kill a running live query
async db.query<T>(sql,vars)Runs a set of SurrealQL statements against the database
async db.select<T>(thing)Selects all records in a table, or a specific record
async db.create<T,U>(thing,data)Creates a record in the database
async db.insert<T,U>(thing,data)Inserts one or multiple records in the database
async db.update<T,U>(thing,data)Updates all records in a table, or a specific record
async db.merge<T,U>(thing,data)Modifies all records in a table, or a specific record
async db.patch<T,U>(thing,data)Applies JSON Patch changes to all records in a table, or a specific record
async db.delete<T,U>(thing,data)Deletes all records, or a specific record
© SurrealDB GitHub Discord Community Cloud Features Releases Install