# moov-database

> Database for moov

Latest version **1.2.3** (published 2016-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install moov-database
pnpm add moov-database
yarn add moov-database
bun add moov-database
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2016-09-20 |
| First published | 2016-08-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | uselessdev |
| Maintainers | uselessdev |
| Keywords | Moov, Database, Json |

## Links

- npm: https://www.npmjs.com/package/moov-database
- Repository: https://github.com/moov-org/database
- Homepage: https://github.com/moov-org/database#readme
- Issues: https://github.com/moov-org/database/issues
- npm.io page: https://npm.io/package/moov-database

## Dependencies (1)

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

## 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.2.3 (latest) — 2016-09-20
- 1.1.3 — 2016-08-31
- 0.1.3 — 2016-08-24
- 0.1.2 — 2016-08-24
- 0.1.1 — 2016-08-24

## README

# Database

[![Software License][ico-license]](LICENSE)
![Code Style][ico-standard]
[![Downloads][ico-downloads]][link-downloads]
[![Build Status][ico-travis]][link-travis]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]

[ico-standard]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[ico-downloads]: https://img.shields.io/npm/dt/moov-database.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/moov-org/database/master.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/moov-org/database.svg?style=flat-square
[ico-scrutinizer]:https://img.shields.io/scrutinizer/coverage/g/moov-org/database.svg?style=flat-square

[link-downloads]: http://npmjs.com/package/moov-database
[link-travis]: https://travis-ci.org/moov-org/database
[link-code-quality]: https://scrutinizer-ci.com/g/moov-org/database/?branch=master
[link-scrutinizer]: https://scrutinizer-ci.com/g/moov-org/database/?branch=master

A simple json database storage.

## Get Started

Install the package

```shell
$ [sudo] npm install --save moov-database
```

## Basic Usage

```js
const db = require('moov-database')

db
  .setFile('path/to/your/db.json')
  .add('user', 'uselessdev')
  .store()
```

## API

### .setFile(path/to/your/database.json)

The `setFile` method allow you to set a path for one database per time.

```js
//...

db.seFile('./users.json')

console.log(db.database) // ./users.json

```

### .add(key, value)

Using the `add` method you can push a new data to your `database`

```js
//...

db.add('username', 'donkey')
db.add('useremail', 'donkey@mydonkeymail.com')

// Or you can chain methods...

db
  .add('username', 'donkey')
  .add('useremail', 'donkey@mydonkeymail.com')

console.log(db.data) // {username: 'donkey', useremail: 'donkey@mydonkeymail.com'}

```

### .massive()

Using the `massive` method you can store an whole object at once to your ` database`

```js
//...

db.massive({
  users: [
    {name: 'donkey', email: 'donkey@mydonkeymail.com'},
    {name: 'cow', email: 'cow@mycowmail.com'}
  ]
})

console.log(db.data)
// {
//    users: [
//      {name: 'donkey', email: 'donkey@mydonkeymail.com'},
//      {name: 'cow', email: 'donkey@mycowmail.com'}
//    ]
// }
```

### .store()
The `store` method will save the stored data in to a `.json` file

```js
//...

db.store()
```

### .get()

Using the `get` method you can retrieve all data stored in database, or you can retrieve a single result by passing his `key` name

```js
//...

db.get('users')
// [
//   {name: 'donkey', email: 'donkey@mydonkeymail.com'},
//   {name: 'cow', email: 'donkey@mycowmail.com'}
// ]

```

### Example:

```js

const database = require('moov-database')
const db = database.setFile('./users.json')

db
  .massive({
    users: [
      {name: 'donkey', email: 'donkey@mydonkey.com'},
      {name: 'cow', email: 'cow@mycow.com'}
    ]
  })
  .add('count_users', db.get('users').length)
  .store()

db.get()
// will return
//
// {
//    users: [
//      {name: 'donkey', email: 'donkey@mydonkey.com'},
//      {name: 'cow', email: 'cow@mycow.com'}
//    ],
//    count_users: 2
// }
//
//

```

## CHANGELOG

[changelog](changelog.md)

## CONTRIBUTING

[contributing](contributing.md)

## LICENSE

[MIT](LICENSE)

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