# origindb-new

> Blazing fast and flexible JSON database.

Latest version **1.1.0** (published 2025-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install origindb-new
pnpm add origindb-new
yarn add origindb-new
bun add origindb-new
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-03-01 |
| First published | 2025-03-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 4 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Clark Jones |
| Maintainers | professor-showdown |
| Keywords | PokemonShowdown, database, json, file, mongo, extendable, flexible |

## Links

- npm: https://www.npmjs.com/package/origindb-new
- Repository: https://github.com/Professor-Showdown/origindb-updated
- Homepage: https://github.com/Professor-Showdown/origindb-updated#readme
- Issues: https://github.com/Professor-Showdown/origindb-updated/issues
- npm.io page: https://npm.io/package/origindb-new

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [mongodb](https://npm.io/package/mongodb.md) ^5.7.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.11
- [json-parse-helpfulerror](https://npm.io/package/json-parse-helpfulerror.md) ^1.0.3

## 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

- 1.1.0 (latest) — 2025-03-01
- 1.0.1 — 2025-03-01
- 1.0.0 — 2025-03-01

## README

# 🏆 OriginDB Updated

<p align="center">
  <b>Blazing fast and flexible JSON database for Node.js.</b>
</p>

<p align="center">
  <img src="https://img.shields.io/badge/Node.js-18%2B-brightgreen" alt="Node.js 18+">
  <img src="https://img.shields.io/badge/MongoDB-4%2B-blue" alt="MongoDB 4+">
  <img src="https://img.shields.io/badge/License-MIT-yellow" alt="MIT License">
</p>

---

## ✨ Features  
✅ **Simple and lightweight** JSON-based database.  
✅ Supports **file storage** and **MongoDB** adapters.  
✅ **Chainable methods** for easy manipulation.  
✅ Fully compatible with **Node.js 18+**.  

---

## 📦 Installation  
Make sure you have **Node.js 18+** installed, then run:  

```sh
npm install origindb-new
```

---

## 🚀 Usage  
### 📂 Using File Storage (JSON-based)
```js
const OriginDB = require('origindb-new');

const db = new OriginDB('files', './data'); // Stores data in "./data"
const money = db.money('wallets');

// 🔹 Add a wallet
money.set('john_doe', { balance: 100, currency: 'USD' });

// 🔹 Get wallet data
console.log(money.get('john_doe')); // { balance: 100, currency: 'USD' }

// 🔹 Check if a wallet exists
console.log(money.has('john_doe')); // true

// 🔹 Get all wallet keys
console.log(money.keys()); // ['john_doe']

// 🔹 Get all wallet values
console.log(money.values()); // [{ balance: 100, currency: 'USD' }]

// 🔹 Update wallet balance
money.update('john_doe', (data) => ({ ...data, balance: data.balance + 50 }));

// 🔹 Delete a wallet
money.unset('john_doe');

// 🔹 Check the full wallets object
console.log(money.object()); // {}
```

### ☁️ Using MongoDB  
Ensure you have a **MongoDB instance running**, then use:  

```js
const OriginDB = require('origindb-new');

const db = new OriginDB('mongo', 'mongodb://localhost:27017/mydatabase'); // Connects to MongoDB
const money = db.money('wallets');

// 🔹 Add a wallet
money.set('jane_doe', { balance: 250, currency: 'EUR' });

// 🔹 Get wallet data
console.log(money.get('jane_doe')); // { balance: 250, currency: 'EUR' }

// 🔹 Check if a wallet exists
console.log(money.has('jane_doe')); // true

// 🔹 Get all wallet keys
console.log(money.keys()); // ['jane_doe']

// 🔹 Get all wallet values
console.log(money.values()); // [{ balance: 250, currency: 'EUR' }]

// 🔹 Update wallet balance
money.update('jane_doe', (data) => ({ ...data, balance: data.balance - 50 }));

// 🔹 Delete a wallet
money.unset('jane_doe');

// 🔹 Check the full wallets object
console.log(money.object()); // {}
```

---

## 📜 API Reference  

| Method | Description |
|--------|-------------|
| **`db.money(name)`** | Creates or retrieves a money storage table (previously `db.table`). |
| **`money.set(key, value)`** | Stores a value under the specified key. |
| **`money.get(key)`** | Retrieves the value stored under the key. |
| **`money.has(key)`** | Checks if a key exists in the table. |
| **`money.keys()`** | Returns all keys in the table. |
| **`money.values()`** | Returns all values in the table. |
| **`money.update(key, callback)`** | Modifies an existing entry using a callback function. |
| **`money.unset(key)`** | Deletes an entry from the table. |
| **`money.object()`** | Returns the entire table object. |

---

## 📌 Requirements  
✅ **Node.js 18+**  
✅ **MongoDB 4+** (only if using MongoDB adapter)  

---

## 📜 License  
This project is licensed under the **MIT License**.  

---

## 👨‍💻 Contributors  
Originally developed by **Phil (CreaturePhil)**  
Updated for **Node.js 18+ and MongoDB 5+ compatibility**.  

---

## ⭐ Support  
If you like this project, please consider **starring** ⭐ the repository!

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