# @nlfmt/stormdb

> A simple typesafe JSON ORM Database with advanced querying and object serialization. Supports NodeJS and Electron

Latest version **2.0.0** (published 2025-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nlfmt/stormdb
pnpm add @nlfmt/stormdb
yarn add @nlfmt/stormdb
bun add @nlfmt/stormdb
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-04-04 |
| First published | 2023-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 24.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | nlfmt |
| Maintainers | nlfmt |
| Keywords | json, database, orm, typescript, typesafety, electron |

## Links

- npm: https://www.npmjs.com/package/@nlfmt/stormdb
- Repository: https://github.com/nlfmt/stormdb
- Homepage: https://github.com/nlfmt/stormdb#readme
- Issues: https://github.com/nlfmt/stormdb/issues
- npm.io page: https://npm.io/package/@nlfmt/stormdb

## Dependencies (1)

- [@typeschema/main](https://npm.io/package/@typeschema/main.md) ^0.14.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-04-04
- 1.0.0 — 2024-02-03
- 0.1.2 — 2023-03-25
- 0.1.1 — 2023-03-25
- 0.0.1 — 2023-03-25

## README

# Storm DB
A **S**imple **T**ypescript **ORM** for NodeJS. Supports custom class serialization and deserialization, advanced querying, and more.

## Disclaimer
### Pros
StormDB is a good choice for projects, that need a simple typesafe database, that works out of the box. \
Since all the data is stored in JSON (or a format of your choice), you dont have to set up anything like a server. \
StormDB can be used in any project you wish, as it is very lightweight.

### Cons
StormDB is **NOT** a good choice to store large amounts of data, as it loads the entire database into memory. \
It is also not suitable for applications that need very fast data access. Even though StormDB is quite fast, as the data is stored in memory, \
it doesnt do any querying optimizations, like indexing.


## Quickstart
1. Install StormDB `npm install @nlfmt/stormdb`
2. Install packages for you validation library, here are some examples:
   - `npm install zod @typeschema/zod`
   - `npm install valibot @typeschema/valibot`
3. Initialize the database
```ts
import StormDB from '@nlfmt/stormdb';
import { z } from 'zod';

const userModel = z.object({
  name: z.string(),
  age: z.number(),
});

const db = StormDB({ user: userModel }, { storage: "db.json" });
```
4. Use the querying API
```ts
// Add a user
let usr = await db.user.create({ name: "John", age: 20 });

// Get a user
usr = await db.user.findById(usr._id);
usr = await db.user.find({ name: "John" });

// Update a user
usr = await db.user.updateById(usr._id, { age: 21 });
usr = await db.user.update({ name: "John" }, { age: 21 });

// Delete a user
await db.user.deleteById(usr._id);
```
## Examples
For more examples, check out the `examples` folder.

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

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