S

Loading…

Class

SinterClient

A connection to a SinterDB server.

Create a client from a sinterdb:// connection string, call connect(), and then use db() to reach databases and collections. Commands sent before connect() completes throw a SinterClientStateError. Call close() when finished.

class SinterClient extends EventEmitter<SinterClientEvents>

Defined in packages/driver/src/client.ts:150

Hierarchy

  • EventEmitter<SinterClientEvents>
    • SinterClient

Constructors#

Properties#

Accessors#

Methods#

M

close

#
close(): Promise<void>

Closes the connection. Requests still waiting for a response fail. Closing a closed client does nothing.

Defined in packages/driver/src/client.ts:356

M

connect

#
connect(): Promise<SinterClient>

Opens the connection and performs the protocol handshake.

Calling connect() on a connected client resolves immediately, and concurrent calls share one attempt. If the attempt fails, the client returns to new and connect() may be tried again. A closed client rejects with a SinterClientStateError.

Returns Promise<SinterClient>

This client, so calls can be chained.

Defined in packages/driver/src/client.ts:223

M

db

#
db(name?: string): SinterDatabase

Returns a handle to a database.

The handle is created locally; no request is sent, and the database is created on the server by the first write. Without name, the database from the connection string is used.

Throws

SinterNamespaceError when neither is available, or when the name is invalid.

Parameters

name?: string

The database name. Optional when the connection string names one.

Defined in packages/driver/src/client.ts:340

M

executeCommand

#
executeCommand(
  database: string | undefined,
  command: string,
  parameters: Document,
): Promise<DocumentValue>

Sends a command by name and returns the raw result.

This is the low-level entry point behind the collection and database methods. Prefer those; the command names and parameters are part of the wire protocol, not of the typed API.

Parameters

database: string | undefined

The database to run the command in, or undefined for server-wide commands.

command: string

The command name.

parameters: Document

The command parameters.

Defined in packages/driver/src/client.ts:299

Used by#