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#
constructor
#new SinterClient(connectionString: string, options?: SinterClientOptions)Defined in packages/driver/src/client.ts:170
Properties#
connectTimeoutMS
#readonly connectTimeoutMS: numberThe effective connect timeout in milliseconds.
Defined in packages/driver/src/client.ts:156
requestTimeoutMS
#readonly requestTimeoutMS: numberThe effective request timeout in milliseconds.
Defined in packages/driver/src/client.ts:158
socketTimeoutMS
#readonly socketTimeoutMS: numberThe effective idle socket timeout in milliseconds, or 0 when disabled.
Defined in packages/driver/src/client.ts:162
target
#readonly target: ParsedSinterConnectionStringThe host, port and optional database parsed from the connection string.
Defined in packages/driver/src/client.ts:154
Accessors#
connected
#get connected(): booleanWhether the client is connected and ready for commands.
Defined in packages/driver/src/client.ts:201
serverInfo
#get serverInfo(): SinterServerInfo | undefinedWhat the server reported during the handshake, or undefined while the
client is not connected.
Defined in packages/driver/src/client.ts:209
state
#get state(): SinterClientStateThe current lifecycle state.
Defined in packages/driver/src/client.ts:196
Methods#
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
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
db
#db(name?: string): SinterDatabaseReturns 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?: stringThe database name. Optional when the connection string names one.
Defined in packages/driver/src/client.ts:340
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 | undefinedThe database to run the command in, or
undefinedfor server-wide commands.command: stringThe command name.
parameters: DocumentThe command parameters.
Defined in packages/driver/src/client.ts:299
listDatabases
#listDatabases(): Promise<string[]>Lists the names of the databases on the server.
Defined in packages/driver/src/client.ts:322
ping
#ping(): Promise<SinterPingResult>Sends a ping to the server and measures the round trip.
Defined in packages/driver/src/client.ts:267