# Private tables

Personal queries and decrypted subscriptions.

[Read the private tables guide](/docs/private-tables/). Signatures below come from the published SDK declarations. Access SDK services through `db`; use their constructors only when integrating at a lower level.

## NostrbasePrivateTables


```ts
/** Personal tables: ciphertext is public, plaintext is available only to its author. */
declare class NostrbasePrivateTables<
  DB extends SchemaShape<DB>,
> implements QueryHost {}
```

### constructor


```ts
constructor(host: NostrbaseClient<DB>);
```

### from


```ts
from<K extends keyof DB & string>(table: K): QueryBuilder<DB[K]>;
```

### decode


```ts
decode<T extends object>(event: NostrEvent, table: string): Promise<Row<T> | null>;
```

### execute


```ts
execute<T extends object>(
  table: string,
  state: QueryState,
): Promise<Result<Row<T>[]>>;
```

### subscribe


```ts
subscribe<K extends keyof DB & string>(
  table: K,
  callback: (change: ChangePayload<DB[K]>) => void,
  onError?: (error: NostrbaseError) => void,
): Promise<{
  unsubscribe(): void;
}>;
```

### close


```ts
close(): void;
```
