nostrbasedocs
Start building
API reference
.md

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

zodTable

/** Pass a Zod schema to validate both writes and incoming records. Transforms are not applied. */
declare function zodTable<T extends object>(
  schema: ZodType<T>,
  options?: Omit<TableDefinition<T>, "validate">,
): TableDefinition<T>;

defineTable

declare function defineTable<T extends object>(
  definition: TableDefinition<T>,
): TableDefinition<T>;

defineSchema

declare function defineSchema<DB extends SchemaShape<DB>>(schema: {
  [K in keyof DB]: TableDefinition<DB[K]>;
}): {
  [K in keyof DB]: TableDefinition<DB[K]>;
};

InferDatabase

type InferDatabase<S> = {
  [K in keyof S]: S[K] extends TableDefinition<infer T> ? T : never;
};

Search guides, API methods, and protocols.