# quick.db-map

> quick.db-map is a quick.db extention which allows

Latest version **1.0.15** (published 2022-01-26) · GPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install quick.db-map
pnpm add quick.db-map
yarn add quick.db-map
bun add quick.db-map
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.15 |
| Published | 2022-01-26 |
| First published | 2021-10-30 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.6.0 |
| Dependencies | 6 |
| Unpacked size | 54.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Nigelrex |
| Maintainers | nigelrex |
| Keywords | quick.db, map, database, db, quick.db-map, json, storing, values, easy, quick, sqlite, sqlite3, db |

## Links

- npm: https://www.npmjs.com/package/quick.db-map
- Repository: https://github.com/Nigelrex/quick.db-map
- Homepage: https://github.com/Nigelrex/quick.db-map#readme
- Issues: https://github.com/Nigelrex/quick.db-map/issues
- npm.io page: https://npm.io/package/quick.db-map

## Dependencies (6)

- [ms](https://npm.io/package/ms.md) 2.1.3
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [moment](https://npm.io/package/moment.md) ^2.29.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^10.0.0
- [quick.db](https://npm.io/package/quick.db.md) github:nigelrex/quick.db
- [picocolors](https://npm.io/package/picocolors.md) ^1.0.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.0.15 (latest) — 2022-01-26
- 1.0.14 — 2022-01-26
- 1.0.13 — 2022-01-26
- 1.0.12 — 2021-11-27
- 1.0.11 — 2021-11-18
- 1.0.10 — 2021-11-12
- 1.0.9-r1 — 2021-11-10
- 1.0.90 — 2021-11-10
- 1.0.9 — 2021-11-10
- 1.0.8 — 2021-11-06
- 1.0.7 — 2021-11-03
- 1.0.6 — 2021-11-03
- 1.0.5 — 2021-11-03
- 1.0.4 — 2021-11-02
- 1.0.3 — 2021-10-30
- … 3 more at https://npm.io/package/quick.db-map/versions

## README

<div align="center">
<img src="./logo.png" align="center">
<br>
<strong>A wrapper around of quick.db but with the superpowers of <i>Map</i> and many new features.</strong>
<br>
<br>
<img src="https://img.shields.io/github/stars/nigelrex/quick.db-map?color=red&label=Repo%20Stars&style=for-the-badge" /> 
<br>
</div>

### Table of Contents

- [Installation](#installation)
- [Credits](#credits)
- [Changelog](#changelog)

### Latest Version:

quick.db-map@1.0.10

## Credits

> [quick.db](https://npmjs.com/package/quick.db) Install this too in your dependencies

> [quick.db Website](https://quickdb.js.org) For vanilla documentation

> [quick.db Discord server](https://discord.gg/plexidev) Join it seriously

## Installation

_If you're having trouble installing, please follow [this troubleshooting guide](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/troubleshooting.md)._

### Linux & Windows

- `npm i quick.db quick.db-map`

**Note:** Windows users may need to do additional steps [listed here](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/troubleshooting.md).

### Mac

1. **Install:** XCode
2. **Run:** `npm i -g node-gyp` in terminal
3. **Run:** `node-gyp --python /path/to/python2.7` (skip this step if you didn't install python 3.x)
4. **Run:** `npm i quick.db quick.db-map`

#

Cached database usage

```js
const Database = require("quick.db-map");
//NOTE: table name is not a required parameter, if nothing is provided it does not create a table, and uses the default plain db
const db = new Database({ tableName: "abc", cache: true, clearCache: true }); //clearCache is a boolean and it will clear the cache every 5 minutes by default
//dbPath is a optional parameter, if nothing is provided it will use the default storage location
db.set("a", "b");
console.log(db.get("a")); //returns b
```

Clear cache at intervals (Other Options)

```js
const Database = require("quick.db-map");
const db = new Database({
  tableName: "abc",
  cache: true,
  clearCache: true,
  maxCacheLimit: 250,
  clearCacheInterval: "30s 10m 5h 2d 3w",
  verbose: true,
}); //maxCacheLimit is the maximum amount of cache that can be stored, clearCacheInterval will override the default 5 minutes interval <30s 10m 5h 2d 3w> [30seconds, 10minutes, 5hours, 2days, 3weeks]

//setting verbose to true will log the events happening
db.set("a", "b");
console.log(db.get("a")); //returns b
```

All Functions

```js
const Database = require("quick.db-map");
const db = new Database({
  dbPath: "./Databases/mydatabasename.db",
  tableName: "abc",
  cache: true,
  clearCache: true,
  maxCacheLimit: 1,
  clearCacheInterval: "4s",
  expiryInterval: "20s",
  verbose: true,
});

db.set("a", "b"); //sets b in value a
//Objects and Arrays also work!

db.get("a"); //returns b

db.has("a"); //returns true

db.delete("a"); //deletes a

db.has("a"); //returns false

db.set("a", { a: "b" }); //sets b in value a in the object

db.set("a.b", "abc"); //sets this as an object

db.deleteAll(); //WARNING! clears the entire database

db.ClearCache(); //Clears the database

db.cacheSize(); //returns the size of the cache

db.set("arandomnumber", 1);

db.add("arandomnumber", 20); //adds 1+20 to the value of arandomnumber and returns 21

db.subtract("arandomnumber", 10); //subtracts 10 from the value of arandomnumber and returns 11

db.set("an Array", [1, 2, 3, "b r u h meme", 6, 8, 2, 5, 7, 3, "meme bro?"]); //set a value as a array

db.push("an Array", 4); //adds 4 to the array and returns [1, 2, 3, 4]

db.reCache(); //re-caches the entire database into the cache

db.backup({ name: "MY DATABASE", path: "./" }); //backup the database

db.expiry("a", { m: 2 }); // expiry goes like this as Object only "{ y:2010, M:3, d:5, h:15, m:10, s:3, ms:12}" or "{ years:2010, months:3, days:5, hours:15, minutes:10, s:3, miliseconds:123}" and deletes "a" after 2 months

console.log(db.pull("an Array", "b r u h meme")); // removes "b r u h meme" from the array

console.log(db.sort("an Array")); // sorts the array and returns "Strings" in the first and then the "Numbers"

console.log(db.reverse("an Array")); // reverses the array

console.log(db.remove("an Array", (value) => value === "b r u h meme")); // removes "b r u h meme" from the array

db.setMany([
  { key: "KEY-1", value: "VALUE-1" },
  { key: "KEY-2", value: "VALUE-2" },
  { key: "KEY-3", value: "VALUE-3" },
]);
```

#

## Changelog

> Added Pull, sort and reverse All Array related features

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