# jovo-db-filedb

> > To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-filedb

Latest version **3.6.1** (published 2022-02-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install jovo-db-filedb
pnpm add jovo-db-filedb
yarn add jovo-db-filedb
bun add jovo-db-filedb
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.6.1 |
| Published | 2022-02-17 |
| First published | 2018-12-01 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 38.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | jovotech |
| Maintainers | jovotech |

## Links

- npm: https://www.npmjs.com/package/jovo-db-filedb
- npm.io page: https://npm.io/package/jovo-db-filedb

## Dependencies (4)

- [jovo-core](https://npm.io/package/jovo-core.md) ^3.6.1
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [lodash.set](https://npm.io/package/lodash.set.md) ^4.3.2
- [lodash.merge](https://npm.io/package/lodash.merge.md) ^4.6.2

## Recent versions

- 3.6.1 (latest) — 2022-02-17
- 2.0.2 (beta) — 2018-12-20
- 2.0.1-alpha.13 (alpha) — 2018-12-10
- 3.6.0 — 2021-11-18
- 3.5.1 — 2021-03-26
- 3.5.0 — 2021-02-22
- 3.4.1 — 2021-02-09
- 3.4.0 — 2021-02-04
- 3.3.1 — 2021-01-27
- 3.3.0 — 2020-12-03
- 3.2.2 — 2020-11-20
- 3.2.1 — 2020-11-10
- 3.2.0 — 2020-10-29
- 3.1.5 — 2020-10-23
- 3.1.4 — 2020-10-16
- … 78 more at https://npm.io/package/jovo-db-filedb/versions

## README

# FileDB Local JSON Database Integration

> To view this page on the Jovo website, visit https://v3.jovo.tech/marketplace/jovo-db-filedb

Learn more about the default database for prototyping with Jovo: A file based system that stores user specific data to a JSON file.

* [Introduction](#introduction)
* [Configuration](#configuration)


## Introduction

> Note: This database type is not supposed to be used in production. See other [database integrations](https://v3.jovo.tech/docs/databases) for options when the app is live. 

The FileDB integration allows you to easily store user session data in a JSON file. This is especially helpful for local development and prototyping. Data will be stored to a `db.json` file that can be found in a `db` folder:

```javascript
db/
  └── db.json
models/
src/
project.js
```

This is an example how the file structure looks like, with the `userID` as a mainKey and some persisted data with `someKey` and `someValue`, which can be added with `this.$user.$data.someKey = 'someValue';`:

```js
// Example for Amazon Alexa
[
	{
		"userId": "amzn1.ask.account.[some_user_id]",
		"userData": {
			"data": {
				"someKey": "someValue"
			},
			"metaData": {
				"createdAt": "2017-11-13T13:46:37.421Z",
				"lastUsedAt": "2017-11-13T14:12:05.738Z",
				"sessionsCount": 9
			}
		}
	}
]
```

## Configuration

Most Jovo templates come with FileDB as default database integration.

It can be enabled in the `src/app.js` file like this:

```javascript
// @language=javascript

// src/app.js

const { FileDb } = require('jovo-db-filedb');

// Enable DB after app initialization
app.use(new FileDb());

// @language=typescript

// src/app.ts

import { FileDb } from 'jovo-db-filedb';

// Enable DB after app initialization
app.use(new FileDb());
```

In your `config.js` file, you can set the `db` configuration like this:

```javascript
// @language=javascript

// src/config.js

module.exports = {
    
    db: {
		FileDb: {
			pathToFile: '../db/db.json',
		},
	},

    // ...

};

// @language=typescript

// src/config.ts

const config = {
    
    db: {
		FileDb: {
			pathToFile: '../db/db.json',
		},
	},

    // ...

};
```


Once the configuration is done, the File DB database integration will create a file in the specified folder (eg. `../db/db.json`) on the first read/write attempt. No need for you to create the file.

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