Entity Manager implements rational indexing & cross-shard querying at scale in your NoSQL database so you can focus on your application logic.
This repository presents a working demonstration of Entity Manager in action. See the companion article for a detailed explanation!
Prereqs
Install and run tests:
npm i
npm test
The first test run will pull the DynamoDB Local Docker image and may take a couple of minutes. Subsequent runs are fast.
This project uses DynamoDB Local via Docker. The tests handle container lifecycle automatically:
Port can be configured by setting DYNAMODB_LOCAL_PORT (default 8000). See .env and .env.local.template.
Everything is TypeScript-first with strong inference. Handlers stay small by delegating key generation, sharding, and cross-index querying to Entity Manager and the DynamoDB adapter.
Create a user and then search by name:
import { createUser, searchUsers } from './src/handlers';
// Create a user record
const user = await createUser({
userId: undefined, // will be generated
beneficiaryId: 'BEN123',
firstName: 'Ada',
lastName: 'Lovelace',
});
// Find by name prefix (case/whitespace/diacritics insensitive)
const result = await searchUsers({ name: 'lov' });
console.log(result.items.map((u) => `${u.firstName} ${u.lastName}`));
Under the hood:
pageKeyMap for the next callas const) so TypeScript can infer tokens and index names.debug while leaving error intact. Flip it on in src/util/logger.ts if you want to see the wire-level details.npm run test — run integration tests (DynamoDB Local via Docker)npm run typecheck — TypeScript typechecknpm run lint — ESLint (Prettier integrated)npm run docs — typedoc (docs build used in the API docs link above)Built for you with ❤️ on Bali! Find more great tools & templates on my GitHub Profile.