Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nlfmt/stormdb
Simple but feature-rich JSON database for NodeJS. Supports custom class serialization and deserialization, advanced querying, and more.
https://github.com/nlfmt/stormdb
database electron javascript json node nodejs orm typesafety typescript
Last synced: 3 months ago
JSON representation
Simple but feature-rich JSON database for NodeJS. Supports custom class serialization and deserialization, advanced querying, and more.
- Host: GitHub
- URL: https://github.com/nlfmt/stormdb
- Owner: nlfmt
- License: mit
- Created: 2023-03-20T23:26:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T01:51:13.000Z (about 1 year ago)
- Last Synced: 2024-11-06T17:57:58.272Z (3 months ago)
- Topics: database, electron, javascript, json, node, nodejs, orm, typesafety, typescript
- Language: TypeScript
- Homepage:
- Size: 119 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
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 necessary packages `npm install @nlfmt/stormdb zod`
2. 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" });
```
3. 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.