Read the configure the client guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.
NostrbaseClient
declare class NostrbaseClient<
DB extends SchemaShape<DB> = DefaultSchema,
> implements QueryHost {}
Properties
readonly auth: NostrbaseAuth;
readonly pool: RelayPool;
readonly eventStore: EventStore;
readonly transport: Transport;
readonly events: NostrbaseEvents;
readonly diagnostics: NostrbaseDiagnostics;
readonly persistence?: NostrbasePersistence;
readonly offline: NostrbaseOffline;
readonly sync: NostrbaseSync;
readonly private: NostrbasePrivateTables<DB>;
readonly groups: NostrbaseGroups<DB>;
readonly storage: NostrbaseStorage<DB>;
readonly backup: NostrbaseBackup;
readonly relations: NostrbaseRelations<DB>;
readonly migrations: NostrbaseMigrations<DB>;
readonly dashboard: NostrbaseDashboard;
readonly ingested$: rxjs.Observable<NostrEvent>;
readonly namespace: string;
readonly relays: string[];
readonly timeout: number;
readonly minWriteAcks: number;
constructor
constructor(options: ClientOptions<DB>);
ready
ready(): Promise<void>;
nextTimestamp
nextTimestamp(address: string): number;
cachedEvents
cachedEvents(): NostrEvent[];
assertOpen
assertOpen(): void;
signal
signal(signal?: AbortSignal): AbortSignal;
definition
definition<T extends object>(table: string): TableDefinition<T> | undefined;
assertTable
assertTable(table: string): void;
from
from<K extends keyof DB & string>(table: K): QueryBuilder<DB[K]>;
request
request(filters: Filter[], signal?: AbortSignal): Promise<TransportRead>;
ingest
ingest(event: NostrEvent): boolean;
isDeleted
isDeleted(event: NostrEvent): boolean;
readTable
readTable<T extends object>(
table: string,
state: QueryState,
authors?: string[] | undefined,
definition?: TableDefinition<T> | undefined,
): Promise<{
rows: Row<T>[];
meta: ResultMeta;
}>;
sign
sign(template: EventTemplate, expectedPubkey?: string): Promise<NostrEvent>;
publish
publish(event: NostrEvent, signal?: AbortSignal): Promise<WriteReceipt>;
executeInGroup
/** Execute the query only within a stored private Marmot group. */
executeInGroup<T extends object>(
groupId: string,
table: string,
state: QueryState,
): Promise<Result<Row<T>[]>>;
execute
execute<T extends object>(
table: string,
state: QueryState,
): Promise<Result<Row<T>[]>>;
channel
channel(name: string, options?: ChannelOptions): NostrbaseChannel<DB>;
removeChannel
removeChannel(channel: NostrbaseChannel<DB>): Promise<void>;
removeAllChannels
removeAllChannels(): Promise<void>;
trackEventSubscription
trackEventSubscription(dispose: () => void): () => void;
close
close(): void;
closeAsync
closeAsync(): Promise<void>;
[Symbol.dispose]
[Symbol.dispose](): void;
createClient
declare function createClient<DB extends SchemaShape<DB> = DefaultSchema>(
options: ClientOptions<DB>,
): NostrbaseClient<DB>;