# @x12i/memorix-db-router

> Canonical database-name routing for Memorix data and metadata databases.

Latest version **3.0.2** (published 2026-07-23) · exellix-license license · 0 weekly downloads

## Install

```sh
npm install @x12i/memorix-db-router
pnpm add @x12i/memorix-db-router
yarn add @x12i/memorix-db-router
bun add @x12i/memorix-db-router
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2026-07-23 |
| First published | 2026-07-19 |
| Weekly downloads | 0 |
| License | exellix-license |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 60.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | x12i |
| Keywords | memorix, mongodb, database, routing |

## Links

- npm: https://www.npmjs.com/package/@x12i/memorix-db-router
- Repository: https://github.com/x12i/memorix-mono-repo
- Homepage: https://github.com/x12i/memorix-mono-repo#readme
- Issues: https://github.com/x12i/memorix-mono-repo/issues
- npm.io page: https://npm.io/package/@x12i/memorix-db-router

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 3.0.2 (latest) — 2026-07-23
- 3.0.0 (next) — 2026-07-23
- 3.0.1 — 2026-07-23
- 1.1.0 — 2026-07-23
- 1.0.0 — 2026-07-19

## README

# `@x12i/memorix-db-router`

Canonical **database name routing** for Memorix data and metadata databases.

Given `orgId` (+ optional agent for metadata), produces the physical Mongo database names the platform must use. Prevents ad-hoc connection string / DB naming drift.

## Install

```bash
npm install @x12i/memorix-db-router@3.0.2
```

| Audience | Use this package? |
|----------|-------------------|
| Remote app | **No** |
| Platform / low-level tooling | **Yes** when constructing DB names |

## Core API

```ts
import {
  getMemorixDataDatabaseName,
  getMemorixMetadataDatabaseName,
  physicalDataDatabaseName,
  physicalMetadataDatabaseName,
  parseMemorixDatabaseName,
  validateMemorixDatabaseRoute,
  discoverMemorixScopes,
} from "@x12i/memorix-db-router";
```

Examples:

```text
orgId=g12ops, dataType=knowledge  →  g12ops-memorix-knowledge
orgId=g12ops, dataType=entities   →  g12ops-memorix-entities
orgId=g12ops, dataType=events     →  g12ops-memorix-events
agentId=ops,  metadata (catalox)  →  ops-memorix-catalox
```

Data plane is **orgId**-scoped (`entities` | `events` | `knowledge`). Metadata (Catalox) is **agentId**-scoped. Empty ids use unprefixed defaults (`memorix-entities`, `memorix-catalox`, …).

## Validation / discovery

| Helper | Role |
|--------|------|
| `validateMemorixDatabaseRoute` / `checkMemorixDatabaseRoute` | Reject unsafe / non-canonical names |
| `parseMemorixDatabaseName` | Split physical name → scope parts |
| `discoverMemorixScopes` | Infer org/agent scopes from a list of DB names |

## Docs

- [`documentation/scope-and-tenancy.md`](../documentation/scope-and-tenancy.md)
- Hub: [https://ebooks.memorix.x12i.com](https://ebooks.memorix.x12i.com)

```bash
npm test
```

---
_Source: https://npm.io/package/@x12i/memorix-db-router · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
