@c11/documents-store-pgmq-nestjs
v1.2.1
Published
NestJS library providing a document store backed by PostgreSQL + [pgmq](https://github.com/tembo-io/pgmq). When a document is inserted, a routing event is published to a pgmq topic in the same database transaction — commit delivers the message, rollback s
Downloads
444
Readme
@c11/documents-store-pgmq-nestjs
NestJS library providing a document store backed by PostgreSQL + pgmq. When a document is inserted, a routing event is published to a pgmq topic in the same database transaction — commit delivers the message, rollback suppresses it.
Installation
npm install @c11/documents-store-pgmq-nestjsPeer dependencies
| Package | Version |
|---------|---------|
| @nestjs/common | ^10.0.0 \|\| ^11.0.0 |
| @nestjs/core | ^10.0.0 \|\| ^11.0.0 |
| @nestjs/typeorm | ^10.0.0 \|\| ^11.0.0 |
| typeorm | ^0.3.0 |
Quick start
1. Define a document entity
// order.document.ts
import { Entity, Column } from "typeorm";
import { BaseDocumentEntity } from "@c11/documents-store-pgmq-nestjs";
@Entity({ name: "orders", schema: "documents" })
export class OrderDocument extends BaseDocumentEntity {
@Column("varchar", { length: 255 })
status: string;
}2. Register the module
// app.module.ts
import { DocumentStoreModule } from "@c11/documents-store-pgmq-nestjs";
@Module({
imports: [
// forRootAsync: call ONCE in the root AppModule; synchronous despite the name
DocumentStoreModule.forRootAsync("my-app"),
// forFeature: register entities — can go in root or any feature module
DocumentStoreModule.forFeature([OrderDocument]),
],
})
export class AppModule {}3. Inject the service and insert a document
// order.service.ts
import { DocumentStoreService } from "@c11/documents-store-pgmq-nestjs";
@Injectable()
export class OrderService {
constructor(private readonly store: DocumentStoreService) {}
async create(namespace: string, status: string): Promise<OrderDocument> {
const order = this.store.create(OrderDocument, { namespace, type: "order", status });
return this.store.insert(order); // persists + publishes atomically
}
}LLM / Agent reference
If you are an AI coding assistant (Claude, Copilot, Cursor, etc.), this package ships two machine-readable reference files alongside the compiled output:
llms.txt— concise API signatures and constraints (~120 lines, no examples)llms-full.txt— full reference with annotated TypeScript examplesPath in your project:
node_modules/@c11/documents-store-pgmq-nestjs/llms.txtRead these files instead of scanning the compiled source.
License
PRIVATE
