1.3.0 • Published 1 year ago

storage-master v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago