# flamebase

> Use JSON files as a simple database.

Latest version **2.0.0** (published 2024-09-01) · ISC license · 0 weekly downloads

## Install

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

## 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 | 2.0.0 |
| Published | 2024-09-01 |
| First published | 2023-03-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Flamend |
| Maintainers | flamend |
| Keywords | Database, JSON, Editor |

## Links

- npm: https://www.npmjs.com/package/flamebase
- Repository: https://github.com/Flamend/Flamebase
- Homepage: https://github.com/Flamend/Flamebase#readme
- Issues: https://github.com/Flamend/Flamebase/issues
- npm.io page: https://npm.io/package/flamebase

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

- 2.0.0 (latest) — 2024-09-01
- 1.1.3 — 2023-05-31
- 1.1.2 — 2023-04-02
- 1.1.1 — 2023-03-23

## README

# Flamebase

[![npm](https://img.shields.io/npm/v/flamebase?label=Version&style=for-the-badge)](https://www.npmjs.com/package/flamebase)  

Flamebase is a simple NPM package designed to easily edit JSON files, functioning as a lightweight and straightforward JSON-based database.

## Installation

Install Flamebase using the following command:

```bash
npm i flamebase
```

## Documentation

### Import the Package

```javascript
const Flamebase = require("flamebase");
```

### Database Management

#### Register a Database

```javascript
Flamebase.registerDatabase("database-name-here", "/path/to/jsonfile.json");
```

#### Remove a Database

```javascript
Flamebase.removeDatabase("database-name-here");
```

#### Get All Registered Databases

```javascript
const databases = Flamebase.getDatabases(); // Returns the Databases object
console.log(databases);
```

#### Get Database Stats

```javascript
const stats = Flamebase.getDatabaseStats("database-name-here"); // Returns info like entries, size, createdAt, and modifiedAt
console.log(stats);
```

#### Clear a Database

```javascript
Flamebase.clearDatabase("database-name-here");
```

### Database Operations

#### Write to a Database

```javascript
Flamebase.write({
  Property: "prop1.prop2.prop3",
  Data: "You can put anything here, including objects or arrays",
  AutoAlign: true, // Automatically arrange the file after writing
  Database: "database-name-here",
});
```

#### Remove from a Database

```javascript
Flamebase.remove({
  Property: "prop1.prop2.prop3",
  AutoAlign: true, // Automatically arrange the file after writing
  Database: "database-name-here",
});
```

#### Update a Database

```javascript
Flamebase.update({
  Property: "prop1.prop2.prop3",
  Data: "New data or value of the property",
  AutoAlign: true, // Automatically arrange the file after writing
  Database: "database-name-here",
});
```

### Retrieving Data

#### Get Property Value or Entire Database

```javascript
// Get a specific property value
const getValue = Flamebase.get({
  Property: "prop1.prop2.prop3",
  Database: "database-name-here",
});
console.log(getValue);

// Get the whole database
const getDatabase = Flamebase.get({
  Database: "database-name-here",
});
console.log(getDatabase);
```

### Array Operations

#### Push to an Array

```javascript
Flamebase.pushToArray({
  Property: "prop1.prop2.prop3",
  Value: "New value", // Value to add to the array
  AutoAlign: true, // Automatically arrange the file after writing
  Database: "database-name-here",
});
```

#### Remove from an Array

```javascript
Flamebase.removeFromArray({
  Property: "prop1.prop2.prop3",
  Value: "New value", // Value to remove from the array
  AutoAlign: true, // Automatically arrange the file after writing
  Database: "database-name-here",
});
```

## Support or Suggestions

For support or to share new ideas, connect via Discord:

**Discord:** [@flamend](https://discord.gg/6XZmFKzwMA)

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