0.0.33 • Published 10 months ago

@novemberizing/storage v0.0.33

Weekly downloads
-
License
MPL-2.0
Repository
gitlab
Last release
10 months ago

NOVEMBERIZING STORAGE

ENGLISH | 한국어

Node js JavaScript

Github issues GitHub license GitHub release Npm version


"Novemberizing storage" is a library made in JavaScript that allows you to access storage and easily perform tasks such as creating, deleting, and modifying resources.

The goal of "Novemberizing storage" is to support memory, file system, and database as well as various other storage types so that storage can be changed easily by changing the "URL".

Class Diagram Log

The storage class has adapter: Adapter that executes actual commands and extension: Extension that can define additional commands as members. For example, in the case of a file system, adapter: Adapter basically has simple commands such as get(), set(value), del() to read, write, Only the method that can be deleted is implemented, but if you use extension: ExtensionJson, you can access the Json file and use a specific key value to define and use methods that can search, modify, or delete with a specific key of the Json object. .

const o = new Storage({ url: 'fs://./configure.json' });

console.log(o.set("hello.world", {}));
console.log(o.get("hello"));
console.log(o.del("hello"));

INSTALL

The storage library can be installed using "npm".

npm install --save @novemberizing/storage

USAGE

You can create storage objects with URL and execute commands.

const o = new Storage({ url:"fs://./configure.json" });

console.log(o.set("hello", "world"));
console.log(o.get(""));
console.log(o.del("hello"));

USE MEMORY STORAGE

To create and use memory-based storage, simply specify the protocol (mem:), host, and path in the URL. In the case of memory-based storage, all values in the storage are initialized when the application is created, and all values are lost when the application is closed. However, if an already created memory storage exists while the application is running, the previously saved value can be used.

const o = new Storage({ url: "mem://./configure.json" });

console.log(o.set("hello", "world"));
console.log(o.get(""));
console.log(o.del("hello"));

USE FILE STORAGE

File storage can be created by specifying the protocol (fs:), host, and path in URL just like memory storage. In the case of file storage, unlike memory storage, stored data can be used depending on the existence of a file, independent of application creation and termination.

const o = new Storage({ url: "fs://./configure.json" });

console.log(o.set("hello", "world"));
console.log(o.get(""));
console.log(o.del("hello"));

USE MYSQL DATABASE STORAGE

MYSQL database storage is used by internally creating an adapter that can use the database as a storage. In case of MYSQL database, if you want to use it like a file or memory, you can additionally define and use the extension setting. You can define and use get, set, del to use it like a JSON memory or file.

const o = new Storage({
    url: "mysql://user@localhost:3306/databasename",
    adapter: {
        password: "password"
    },
    extension: {
        get: { sql: "..." },
        set: { sql: "..." },
        del: { sql: "..." },
    }
});

console.log(o.set("hello", "world"));
console.log(o.get(""));
console.log(o.del("hello"));

USE JSON EXTENSION

You can use the JSON extension by specifying .json in the file extension. However, in the case of a database, methods such as get(key): object, set(key, value): object, del(key): object must be defined and used.

const fs = new Storage({ url: "fs://./configure.json" });

console.log(fs.set("hello", "world"));
console.log(fs.get(""));
console.log(fs.del("hello"));

const mem = new Storage({ url: "mem://./configure.json" });

console.log(mem.set("hello", "world"));
console.log(mem.get(""));
console.log(mem.del("hello"));

const mysql = new Storage({
    url: "mysql://user@localhost:3306/db",
    adapter: {
        password: "password"
    },
    extension: {
        get: { sql: "..." },
        set: { sql: "..." },
        del: { sql: "..." },
    }
});

console.log(mysql.set("hello", "world"));
console.log(mysql.get(""));
console.log(mysql.del("hello"));

DOCUMENT

Novemberizing storage api

0.0.33

10 months ago

0.0.32

10 months ago

0.0.31

10 months ago

0.0.30

10 months ago

0.0.29

10 months ago

0.0.28

10 months ago

0.0.27

10 months ago

0.0.26

10 months ago

0.0.25

10 months ago

0.0.24

10 months ago

0.0.23

10 months ago

0.0.21

10 months ago

0.0.20

10 months ago

0.0.19

10 months ago

0.0.18

10 months ago

0.0.17

10 months ago

0.0.16

10 months ago

0.0.15

10 months ago

0.0.14

10 months ago

0.0.13

10 months ago

0.0.11

10 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago