# suchdb

> Real time JSON database, fully loaded into ram.

Latest version **0.2.1** (published 2021-12-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install suchdb
pnpm add suchdb
yarn add suchdb
bun add suchdb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2021-12-29 |
| First published | 2017-08-15 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 21.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Mark Khramko |
| Maintainers | markkhramko |
| Keywords | real-time, database, ram, JSON |

## Links

- npm: https://www.npmjs.com/package/suchdb
- Repository: https://github.com/MarkKhramko/SuchDB
- Homepage: https://github.com/MarkKhramko/SuchDB#readme
- Issues: https://github.com/MarkKhramko/SuchDB/issues
- npm.io page: https://npm.io/package/suchdb

## Dependencies (1)

- [nanoid](https://npm.io/package/nanoid.md) ^3.1.30

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

- 0.2.1 (latest) — 2021-12-29
- 0.2.0 — 2021-12-29
- 0.1.0 — 2021-12-29
- 0.0.1 — 2017-08-15

## README

# SuchDB

* Real-time JS database, fully loaded into memory.

### !Proof of work, not for commercial use!
### !In case of use, please perform all record validation yourself, before insertion in tables.


## Install:
```sh
npm install suchdb
```


## Basic use:

### Insert
```js
const { Database } = require('suchdb');
...
// Create Database.
const db = new Database('real_time_db')

// Create table.
const table = db.createTable('transactions');

// Insert record:
const data = {
	'amount': 90,
	'currency': 'Euro',
	'sender': 'John Appleseed',
	'receiver': 'Steve Props'
};
db.insert('transactions', data);
// or
table.insert(data);
```

### Find
```js
const result = db.findById('transactions', '<uuid>');
// Result (considering data in previous example)
// [
// 	{
//		'id': <uuid>,
//		'amount': 90,
//		'currency': 'Euro',
//		'sender': 'John Appleseed',
//		'receiver': 'Steve Props'
//	}
// ]
```

### Select first or last row
```js
const firstRow = db.selectFirstRow('transactions');
const lastRow = db.selectLastRow('transactions');
````

### Delete
```js
// (considering data in previous example)
db.deleteById('transactions', '<uuid>');
```


## Query usage:
```js
const { Query } = require('suchdb');
...
// Create query object (Notice, that you don't need "new" keyword).
const query = Query().where('amount', '>=', 89).first(10);

// Perform rows selection.
const rows = db.select('transactions', query);
// Result (considering data in previous example)
// [
// 	{
//		'id': <uuid>,
//		'amount': 90,
//		'currency': 'Euro',
//		'sender': 'John Appleseed',
//		'receiver': 'Steve Props'
//	}
// ]
```

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