# kndb

> Kn-DB

Latest version **0.1.0** (published 2020-01-06) · MIT license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2020-01-06 |
| First published | 2019-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| Author | Knove |
| Maintainers | knove |

## Links

- npm: https://www.npmjs.com/package/kndb
- Homepage: https://github.com/Knove/knDB
- npm.io page: https://npm.io/package/kndb

## Dependencies (8)

- [uuid](https://npm.io/package/uuid.md) ^3.3.3
- [immer](https://npm.io/package/immer.md) ^5.1.0
- [rollup](https://npm.io/package/rollup.md) ^1.28.0
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.3
- [rollup-plugin-alias](https://npm.io/package/rollup-plugin-alias.md) ^1.5.1
- [rollup-plugin-babel](https://npm.io/package/rollup-plugin-babel.md) ^4.2.0
- [rollup-plugin-uglify](https://npm.io/package/rollup-plugin-uglify.md) ^6.0.0
- [rollup-plugin-node-resolve](https://npm.io/package/rollup-plugin-node-resolve.md) ^4.0.0

## Recent versions

- 0.1.0 (latest) — 2020-01-06
- 0.0.1 — 2019-01-10

## README

<h1 align="center">Kn-DB</h1>
<div align="center">

 Data persistence, Based on [Node.js](https://nodejs.org)

Data Storage for Lightweight Node.js Applications

[![npm package](https://img.shields.io/npm/v/kndb.svg?style=flat-square)](https://www.npmjs.org/package/kndb)

</div>

English | [简体中文](./README.CN.md)

At present, it is not so much a database as a lightweight data storage. 

If your application does not need to store a large amount of data, then you can consider Kn-DB! Get rid of the shackles of large third-party databases!

## Why use Kn-DB?

- Easy to import, very suitable for storing Non-large data! You can save any information you want to save!
- When promoting your Node.js application, you can avoid users having to install third-party databases (such as mySQL, mongoDB, etc.) to achieve data storage, which is more suitable for promotion.

## Installation

```sh
// with npm
npm install kndb

// with yarn
yarn add kndb
```

## Usage

Here is a quick example to get you started:

```javascript
const knDB = require('kndb');

const db = knDB.getDB('hello');

if (db.success) {
  db.get('knove');       // {}
  db.set('knove', { value: 7 });
  db.get('knove');       // { value: 7 }
} else {
  console.error(db.errorInfo);
}
```
Nested data：
```javascript
// now object is { innerValue: 2 }
const { object } = db.get('knove'); 

object.innerValue = 7;
db.set('knove', { object });

db.get('knove').object.innerValue; // 7
```
Too many levels are not recommended, this is a example of flat levels:
```javascript
db.set('knove', { 
  value1: 0,
  value2: 0
}); 

db.set('knove', { value1: 1 }); 

db.get('knove') // { value1: 1, value2: 0 }
```
Contrast：
```javascript
db.set('knove', { 
  object: { num1: 0, num2: 0 },
}); 

db.set('knove', { object: { num1: 2 } }); 

db.get('knove') // { object: { num1: 2 } }
```
## knDB API
### · getDB(db_name, [option])
Available options:
- type: getDB type, when type = check, if db is undefind, kndb will thorw error, default is create db
   
- position: db saved position, default is your project root position
```javascript
const options = {
    type: 'check',
    position: 'C:\\db', // Linux : 'opt/db/example'
}
const db = knDB.getDB('hello', options);
```
## db API
### · get(table_name)
```javascript
const tableData = db.get('knove'); 
```

### · set(table_name, setData)
```javascript
const setAction = db.set('knove', { a: 7 });
if (setAction.errorInfo) {
    console.error(setAction.errorInfo);
}
```

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