# coffeedb

> Trusted open source and fast accessible easy database.

Latest version **0.1.7** (published 2022-05-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2022-05-29 |
| First published | 2022-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | uzay |
| Keywords | nosql, database, db, to-JSON, opensource, json, jsonbase |

## Links

- npm: https://www.npmjs.com/package/coffeedb
- Repository: https://github.com/mustafa.demirtra/coffeedb
- Homepage: https://github.com/mustafa.demirtra/coffeedb#readme
- Issues: https://github.com/mustafa.demirtra/coffeedb/issues
- npm.io page: https://npm.io/package/coffeedb

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21

## 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.1.7 (latest) — 2022-05-29
- 0.1.6 — 2022-05-29
- 0.1.5 — 2022-05-29
- 0.1.4 — 2022-05-29

## README

<h2>Coffee.db</h2>

[![plusdb](https://img.shields.io/badge/coffee-db-black.svg)](https://www.npmjs.org/package/coffeedb)
[![npm version](https://img.shields.io/npm/v/coffee.db.svg?style=flat-square)](https://www.npmjs.org/package/coffeedb)
[![npm downloads](https://img.shields.io/npm/dm/coffeedb.svg?style=flat-square)](http://npm-stat.com/charts.html?package=coffeedb)
[![Discord](https://img.shields.io/discord/675217083155480577?color=%237289DA&label=Discord)](https://discord.gg/TpNWrwENzr)

> Simple, convenient JSON database for nodejs.

Released v0.1.7 now.
<hr>

# Getting Started

Installing the npm package
```console
$ npm install coffeedb
```
Usage of coffeedb
```js
const { Database } = require("coffeedb");
const db = new Database("myDataBase");
```

<hr>

# Documentation

- [new coffeeDB(settings)](#coffeedb)
  - add(id, value)
  - all()
  - clear()
    - reset()
  - delete(id)
    - remove(id)
  - get(id)
    - fetch(id)
  - has(id)
  - push(id, value)
  - set(id, value)
  - subtract(id, value)
- [DatabaseError](#DatabaseError)

## new typeDB(settings)
<div class="coffeeDB"></div>

Creates or gets a database file
- **Params:**
  - **settings** - An object with the settings
    - **settings.path** - The path of the database (must be an absolute path / the folder should be created) 
    - **settings.spaces** - The spaces of the database file
- **Throws:** [DatabaseError()](#DatabaseError) - If there are no settings or any settings are invalid

## Methods

### add(id, value)
Adds the value of an element in the database
- **Params:**
  - **id** - The ID of the element
  - **value** - The value to be added
- **Returns:** **Number** - Result
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID or value is invalid

### all()
Return the all data on the database
- **Returns:** **Object** - The all data

### clear(id)
Deletes all the data in database / [.reset()](#reset) method is same
- **Returns:** **true** - Indicates that it was cleared

### delete(id)
Deletes element from database / [.remove()](#remove) method is same
- **Params:**
  - **id** - The ID of the element
- **Returns:** **Boolean** - Indicates that it was deleted
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID is invalid

### get(id)
Gets the element on the database / [.fetch()](#fetch) method is same
- **Params:**
  - **id** - The ID of the element
- **Returns:** * - The data
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID is invalid

### has(id)
Checks for data in the database
- **Params:**
  - **id** - The ID of the element
- **Returns:** **Boolean** - Indicates presence
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID is invalid

### push(id, value)
Pushs the data in a array from database
- **Params:**
  - **id** - The ID of the element
  - **value** - The pushed element
- **Returns:** **Array** - The array of the ID
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID or value is invalid

### set(id, value)
Sets the value of an element in the database
- **Params:**
  - **id** - The ID of the element
  - **value** - The value to be setted
- **Returns:** * - The value setted
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID or value is invalid

### subtract(id, value)
Subtracts the value of an element in the database
- **Params:**
  - **id** - The ID of the element
  - **value** - The value to be subtract
- **Returns:** **Number** - Result
- **Throws:** [DatabaseError()](#DatabaseError) - If the ID or value is invalid

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