@codesoul-co/hypha-memory / mongo-structured-store
- Package index:
@codesoul-co/hypha-memory - Source:
packages/memory/src/mongo-structured-store.ts - Exports: 10
Using this module
Use the Mongo structured store module for persisting and reading data at this boundary. It exports 1 class, 1 function, 7 interfaces, 1 type.
Import from the package entrypoint
import {
MongoStructuredStoreProvider,
normalizeMongoStructuredStoreError,
} from '@codesoul-co/hypha-memory';
import type {
MongoCollectionLike,
MongoCursorLike,
MongoDatabaseLike,
MongoOperationOptionsLike,
MongoSessionLike,
MongoStructuredStoreHealth,
MongoStructuredStoreProviderOptions,
MongoTransactionMode,
} from '@codesoul-co/hypha-memory';Usage patterns
- Use the 8 type/interface exports as static contracts in application code, adapters, or tests. Import them with
import type; they do not exist at runtime. - The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
- The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
MongoStructuredStoreProvider | class | new MongoStructuredStoreProvider(options: MongoStructuredStoreProviderOptions, session?: MongoSessionLike | undefined): MongoStructuredStoreProvider | Mongo-backed StructuredStoreProvider without leaking a Mongo SDK into Memory contracts. |
normalizeMongoStructuredStoreError | function | normalizeMongoStructuredStoreError(error: unknown, operation: string): import("./contracts").NormalizedMemoryError | Normalize Mongo Structured Store Error function with 1 public call signature; parameters and return types are listed below. |
MongoCollectionLike | interface | interface MongoCollectionLike | Mongo Collection Like interface with 6 public fields or methods. |
MongoCursorLike | interface | interface MongoCursorLike | Mongo Cursor Like interface with 3 public fields or methods. |
MongoDatabaseLike | interface | interface MongoDatabaseLike | Mongo Database Like interface with 3 public fields or methods. |
MongoOperationOptionsLike | interface | interface MongoOperationOptionsLike | Mongo Operation Options Like interface with 1 public fields or methods. |
MongoSessionLike | interface | interface MongoSessionLike | Mongo Session Like interface with 2 public fields or methods. |
MongoStructuredStoreHealth | interface | interface MongoStructuredStoreHealth | Mongo Structured Store Health interface with 3 public fields or methods. |
MongoStructuredStoreProviderOptions | interface | interface MongoStructuredStoreProviderOptions | Mongo Structured Store Provider Options interface with 3 public fields or methods. |
MongoTransactionMode | type | type MongoTransactionMode = 'required' | 'preferred' | 'disabled' | Public type alias for Mongo Transaction Mode; the declaration contains its complete type expression. |
MongoStructuredStoreProvider
Mongo-backed StructuredStoreProvider without leaking a Mongo SDK into Memory contracts.
- Kind: class
- Import:
import { MongoStructuredStoreProvider } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export declare class MongoStructuredStoreProvider implements StructuredStoreProvider {
constructor(options: MongoStructuredStoreProviderOptions, session?: MongoSessionLike | undefined);
get<T>(table: string, id: string): Promise<T | null>;
insert<T extends {
id: string;
}>(table: string, record: T): Promise<void>;
update<T>(table: string, id: string, patch: Partial<T>): Promise<void>;
compareAndSet<T>(table: string, id: string, expected: Partial<T>, patch: Partial<T>): Promise<boolean>;
delete(table: string, id: string): Promise<void>;
query<T>(table: string, query: StructuredQuery): Promise<T[]>;
transaction<T>(operation: (tx: StructuredStoreProvider) => Promise<T>): Promise<T>;
supportsTransactions(): boolean;
initialize(collections: readonly string[]): Promise<void>;
health(): Promise<MongoStructuredStoreHealth>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
compareAndSet | method | compareAndSet<T>(table: string, id: string, expected: Partial<T>, patch: Partial<T>): Promise<boolean> | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (options: MongoStructuredStoreProviderOptions, session?: MongoSessionLike | undefined): MongoStructuredStoreProvider | Creates an instance of this class. |
delete | method | delete(table: string, id: string): Promise<void> | Public method; parameters and return type are shown in the signature. |
get | method | get<T>(table: string, id: string): Promise<T | null> | Public method; parameters and return type are shown in the signature. |
health | method | health(): Promise<MongoStructuredStoreHealth> | Public method; parameters and return type are shown in the signature. |
initialize | method | initialize(collections: readonly string[]): Promise<void> | Public method; parameters and return type are shown in the signature. |
insert | method | insert<T extends { id: string; }>(table: string, record: T): Promise<void> | Public method; parameters and return type are shown in the signature. |
query | method | query<T>(table: string, query: StructuredQuery): Promise<T[]> | Public method; parameters and return type are shown in the signature. |
supportsTransactions | method | supportsTransactions(): boolean | Public method; parameters and return type are shown in the signature. |
transaction | method | transaction<T>(operation: (tx: StructuredStoreProvider) => Promise<T>): Promise<T> | Public method; parameters and return type are shown in the signature. |
update | method | update<T>(table: string, id: string, patch: Partial<T>): Promise<void> | Public method; parameters and return type are shown in the signature. |
normalizeMongoStructuredStoreError
Normalize Mongo Structured Store Error function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { normalizeMongoStructuredStoreError } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export declare function normalizeMongoStructuredStoreError(error: unknown, operation: string): import("./contracts").NormalizedMemoryError;Call signature
normalizeMongoStructuredStoreError(error: unknown, operation: string): import("./contracts").NormalizedMemoryErrorParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
error | unknown | Yes | Required parameter; accepted values are defined by the type column. |
operation | string | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
NormalizedMemoryError - Description: The return contract is defined by the type shown above.
MongoCollectionLike
Mongo Collection Like interface with 6 public fields or methods.
- Kind: interface
- Import:
import type { MongoCollectionLike } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoCollectionLike {
findOne<T>(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): Promise<T | null>;
insertOne<T extends object>(document: T, options?: MongoOperationOptionsLike): Promise<unknown>;
updateOne(filter: Record<string, unknown>, update: {
$set: Record<string, unknown>;
}, options?: MongoOperationOptionsLike): Promise<{
matchedCount?: number;
}>;
deleteOne(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): Promise<{
deletedCount?: number;
}>;
find<T>(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): MongoCursorLike<T>;
createIndex?(keys: Record<string, 1 | -1>, options?: {
unique?: boolean;
name?: string;
}): Promise<unknown>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
createIndex | method | createIndex?(keys: Record<string, 1 | -1>, options?: { unique?: boolean; name?: string; }): Promise<unknown> | Public method; parameters and return type are shown in the signature. |
deleteOne | method | deleteOne(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): Promise<{ deletedCount?: number; }> | Public method; parameters and return type are shown in the signature. |
find | method | find<T>(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): MongoCursorLike<T> | Public method; parameters and return type are shown in the signature. |
findOne | method | findOne<T>(filter: Record<string, unknown>, options?: MongoOperationOptionsLike): Promise<T | null> | Public method; parameters and return type are shown in the signature. |
insertOne | method | insertOne<T extends object>(document: T, options?: MongoOperationOptionsLike): Promise<unknown> | Public method; parameters and return type are shown in the signature. |
updateOne | method | updateOne(filter: Record<string, unknown>, update: { $set: Record<string, unknown>; }, options?: MongoOperationOptionsLike): Promise<{ matchedCount?: number; }> | Public method; parameters and return type are shown in the signature. |
MongoCursorLike
Mongo Cursor Like interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { MongoCursorLike } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoCursorLike<T> {
sort?(order: Record<string, 1 | -1>): MongoCursorLike<T>;
limit?(limit: number): MongoCursorLike<T>;
toArray(): Promise<T[]>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
limit | method | limit?(limit: number): MongoCursorLike<T> | Public method; parameters and return type are shown in the signature. |
sort | method | sort?(order: Record<string, 1 | -1>): MongoCursorLike<T> | Public method; parameters and return type are shown in the signature. |
toArray | method | toArray(): Promise<T[]> | Public method; parameters and return type are shown in the signature. |
MongoDatabaseLike
Mongo Database Like interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { MongoDatabaseLike } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoDatabaseLike {
collection(name: string): MongoCollectionLike;
startSession?(): MongoSessionLike;
command?(command: Record<string, unknown>): Promise<unknown>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
collection | method | collection(name: string): MongoCollectionLike | Public method; parameters and return type are shown in the signature. |
command | method | command?(command: Record<string, unknown>): Promise<unknown> | Public method; parameters and return type are shown in the signature. |
startSession | method | startSession?(): MongoSessionLike | Public method; parameters and return type are shown in the signature. |
MongoOperationOptionsLike
Mongo Operation Options Like interface with 1 public fields or methods.
- Kind: interface
- Import:
import type { MongoOperationOptionsLike } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoOperationOptionsLike {
session?: MongoSessionLike;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
session | property | session?: MongoSessionLike | Public property; its type, readonly modifier and optionality are shown in the signature. |
MongoSessionLike
Mongo Session Like interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { MongoSessionLike } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoSessionLike {
withTransaction<T>(operation: () => Promise<T>): Promise<T>;
endSession(): Promise<void>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
endSession | method | endSession(): Promise<void> | Public method; parameters and return type are shown in the signature. |
withTransaction | method | withTransaction<T>(operation: () => Promise<T>): Promise<T> | Public method; parameters and return type are shown in the signature. |
MongoStructuredStoreHealth
Mongo Structured Store Health interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { MongoStructuredStoreHealth } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoStructuredStoreHealth {
status: 'healthy' | 'degraded' | 'unhealthy';
transactions: boolean;
message?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
message | property | message?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
status | property | status: "healthy" | "degraded" | "unhealthy" | Public property; its type, readonly modifier and optionality are shown in the signature. |
transactions | property | transactions: boolean | Public property; its type, readonly modifier and optionality are shown in the signature. |
MongoStructuredStoreProviderOptions
Mongo Structured Store Provider Options interface with 3 public fields or methods.
- Kind: interface
- Import:
import type { MongoStructuredStoreProviderOptions } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export interface MongoStructuredStoreProviderOptions {
database: MongoDatabaseLike;
transactionMode?: MongoTransactionMode;
collectionPrefix?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
collectionPrefix | property | collectionPrefix?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
database | property | database: MongoDatabaseLike | Public property; its type, readonly modifier and optionality are shown in the signature. |
transactionMode | property | transactionMode?: MongoTransactionMode | Public property; its type, readonly modifier and optionality are shown in the signature. |
MongoTransactionMode
Public type alias for Mongo Transaction Mode; the declaration contains its complete type expression.
- Kind: type
- Import:
import type { MongoTransactionMode } from '@codesoul-co/hypha-memory'; - Source module:
mongo-structured-store
Declaration
export type MongoTransactionMode = 'required' | 'preferred' | 'disabled';