An easy and quick database
Find a file
dependabot[bot] a797cc6ac4
Bump @types/node from 18.17.1 to 20.4.5
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.17.1 to 20.4.5.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-31 07:29:33 +00:00
.github Create dependabot.yml 2023-02-05 22:15:23 +01:00
src . 2023-04-12 18:37:16 +02:00
.gitignore 2023.02.05-2 2023-02-05 13:17:25 +01:00
.npmrc Reset 2022-11-03 17:53:46 +01:00
package.json Bump @types/node from 18.17.1 to 20.4.5 2023-07-31 07:29:33 +00:00
readme.md fix readme 2023-02-23 10:46:26 +00:00
SECURITY.md rfr 2023-02-06 10:37:32 +01:00
tsconfig.json 2023.02.05-2 2023-02-05 13:17:25 +01:00

Mit.db

const MitDB = require('mit.db');
const db = new MitDB('file.db'); // this is the save file's name + extension
async function sample() {
    // assuming 'somekey' exists in the Map and has a value { cool: false }
    const data = db.get('somekey');
    // reassigning the 'cool' property a new value
    data.cool = true;
    await db.set('somekey', data);
    // now 'somekey' has a new value { cool: true }
}

Docs

Installation

With npm:

npm i mit.db

Setup

const MitDB = require('mit.db')
const db = new MitDB('database.json') // this is the save file's name + extension

set()

    await db.set('ciao', 'hello')
    await db.set('arrivederci', 'bye')

get()

var ansa = db.get('ciao') // ansa = hello

has()

var asnb = db.has('arrivederci') // ansb = true

entries()

var ansc = db.entries() // ansc = [ 'ciao', 'hello' ], [ 'arrivederci', 'bye' ] ]

keys()

var ansd = db.keys() // ansd = [ 'ciao', 'arrivederci' ]

values()

var anse = db.values() // anse = [ 'hello', 'bye' ]

forEach()

db.forEach((value, key) => console.log(value, key)) // console.log = hello ciao
// console.log = bye arrivederci

delete()

// [{"key":"ciao","value":"hello"}, {"key":"arrivederci","value":"bye"}]
await db.delete('ciao')
// [{"key":"arrivederci","value":"bye"}]

clear()

// [{"key":"ciao","value":"hello"}, {"key":"arrivederci","value":"bye"}]
await db.delete('ciao')
// []

size()

// [{"key":"ciao","value":"hello"}, {"key":"arrivederci","value":"bye"}]
var ansf = db.size() // size = 2