nostrbasedocs
Start building
API reference
.md

Read the record references guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.

RecordReference

interface RecordReference<K extends string = string> {
  table: K;
  id: string;
  author: string;
}

reference

declare function reference<K extends string>(
  table: K,
  id: string,
  author: string,
): RecordReference<K>;

NostrbaseRelations

/** References are resolved in the client. They do not enforce foreign keys. */
declare class NostrbaseRelations<DB extends SchemaShape<DB>> {}

constructor

constructor(host: RelationsHost<DB>);

resolve

resolve<K extends keyof DB & string>(
  target: RecordReference<K>,
): Promise<Result<Row<DB[K]>>>;

resolveMany

resolveMany<K extends keyof DB & string>(
  targets: readonly RecordReference<K>[],
): Promise<Result<(Row<DB[K]> | null)[]>>;

Supporting declarations

These types appear in public signatures but are not package exports.

RelationsHost

interface RelationsHost<DB extends SchemaShape<DB>> {
  from<K extends keyof DB & string>(table: K): QueryBuilder<DB[K]>;
}

Search guides, API methods, and protocols.