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
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
- Install the package
npm i json-db-jdb
- Import it
const jdb = require('json-db-jdb/jdb')
- Create database:
// Params: EntityType, EntityName
jdb.create('Db', 'myDatabase')
// run the file and comment out this command
- Create Groups
// Params: EntityType, EntityName
jdb.create('rGroup', 'test_users')
jdb.create('iGroup', 'test_init')
// run file and comment out these 2 lines
- 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
- 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
- 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
- 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
- Edit rGroup elements
// GroupName, Entry, Element-Moral-Object
editR('test_users', '1', {
"name": "spuckhafte",
"pass": "strong_password"
})
// run file and comment out these lines
- 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
- 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