json-db-jdb
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

JDb-cropped

JDb - JSON Database

To get the concept, check:
https://github.com/spuckhafte/JSON-Database

This is the latest version of the JSON Database.
For contribution: Discord: spuckhafte#7109

Logs:

3 March 22
Organized code
Assign() is asynchronous

5 March 22
The morals are encrypted, makes it difficult to read the JSON file

8 March 22
⭐ Morals of rGroup elements can be edited

3 May 22
EncDenc module is handling the encryption

29 May 22
⭐ Update the config (encdenc) from your main file, before: you had to update the node module itself in order to update the config

8 Nov 22
⭐ You can now turn "off" data encryption for your project: jdb.Machine.dataEncryption = false


⚠️You should edit the config array and make it unique for the best use of EncDenc encryption module:

jdb.Machine.config = [ /* unique array */ ]

Read more at https://www.npmjs.com/package/encdenc

How To Use?

  1. Install the package
npm i json-db-jdb
  1. Import it
const jdb = require('json-db-jdb/jdb')
  1. Create database:
// Params: EntityType, EntityName
jdb.create('Db', 'myDatabase')
// run the file and comment out this command
  1. Create Groups
// Params: EntityType, EntityName
jdb.create('rGroup', 'test_users')
jdb.create('iGroup', 'test_init')
// run file and comment out these 2 lines
  1. Create elements in groups
// Params: EntityType, EntityGroup, EntityName
create('element', 'test_users', 'name');
create('element', 'test_users', 'pass');
create('element', 'test_init', 'test');
// run file and comment out these lines
  1. Assign data to iGroup element
// Params: GroupName, ElementName, Prime-Moral-Object 
assignI('test_init', 'test', {
     "test": "test",
     "test2": "255"
})
// run file and comment out these lines
  1. Get the data from iElement ; assign to rGroup elements
// Params: GroupName, ElementName
console.log(getEl('test_init', 'test'));

// Params: GroupName, Element-Moral-Object
assignR('test_users', {
     "name": "user232",
     "pass": "pass2"
})
// run file and comment out these lines
  1. Get whole elements as data or get bits of data from elements
// Params: GroupName, ElementName
console.log(getEl('test_users', 'name'));
console.log(getEl('test_users', 'pass'));

// Params: GroupName, GetWithRespectTo, Query
getR('test_users', 'entry', '1').then(data => console.log(data))
getR('test_users', 'moral', ['name', 'user232']).then(data => console.log(data));
// run file and comment out these lines
  1. Edit rGroup elements
// GroupName, Entry, Element-Moral-Object
editR('test_users', '1', {
     "name": "spuckhafte",
     "pass": "strong_password"
})
// run file and comment out these lines
  1. Get the edited data
// Params: GroupName, GetWithRespectTo, Query
getR('test_users', 'entry', '1').then(data => console.log(data));
getR('test_users', 'moral', ['name', 'spuckhafte']).then(data => console.log(data));
// run file and comment out these lines
  1. Get everything one last time
// Params: GroupName, ElementName
console.log(getEl('test_init', 'test'))
console.log(getEl('test_users', 'name'))
console.log(getEl('test_users', 'pass'))
// run file and comment out these lines

Readme

Keywords

none

Package Sidebar

Install

npm i json-db-jdb

Weekly Downloads

0

Version

3.0.2

License

ISC

Unpacked Size

75.8 kB

Total Files

25

Last publish

Collaborators

  • spuckhafte