storage-master
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

storage-master module

Introduction

A simple module for JSON storing and managing data. Great for small projects, making coding easier and faster!

Installation

Installation from npm

npm i storage-master

Setup Example

This is a small example with which you can easily start using storage-master.

import { resolve } from 'path';
import { Storage } from 'storage-master';

// Specify the path to the storage
const path = resolve('storages', 'users.json');

// Indicate the stored data, its types and default values
const structure = {
  name: {
    type: 'string',
  },
  age: {
    type: 'number',
  },
  is_verified: {
    type: 'boolean',
    default: false,
  },
};

// Create a class for further work with the repository
const storage = new Storage(path, structure);

const userID = 12345;
storage.set(userID, {
  name: 'Kio Gia',
  age: 21,
});

const user = storage.get(userID);
console.log(user);

To use ES6, add to package.json:

"type": "module"

Useful links

Package Sidebar

Install

npm i storage-master

Weekly Downloads

2

Version

1.3.0

License

MIT

Unpacked Size

16.3 kB

Total Files

5

Last publish

Collaborators

  • kiogia