JSPM

  • Created
  • Published
  • Downloads 892
  • Score
    100M100P100Q110563F
  • License MIT

Simple, Supports data encryption & Uses JSON data format

Package Exports

  • st.db

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (st.db) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ST.db

  • Database in JSON format is simple and fast, and you can read data from one project to another and supports data encryption if you want it and many distinct functions

Features

  • Multiple JSON Files
  • Simple and Easy To get started
  • can I switch data from file to file
  • Supports data encryption mode if you want it
  • ٍSupports moving Quick.DB data to ST.db data file
  • System for reading data from one project to another

Getting Started

You can start install the package on your project:

npm i st.db@latest

You can update to a newer version to receive updates using npm.

npm update st.db

Then Start define it like this:

const Database = require('st.db')
const db = new Database('FileName')//You can write the name you want

Important Notes

  • Auto understands json without typing .json in the path
  • For the Database class, you can pass in a parameter to set a file rather than using the default file!
  • If the file dosen't exist, it will create it
  • Path automatically set to ./

How do I turn on data encryption mode?

  • Now your data is encrypted in ST.db encrypt
  • An example of a method for operating an encryption mode and reading encrypted data
const Database = require('st.db')
const db = new Database(`FileName`,{
  encrypt: true,
})

Notes for encryption mode

  • If you activate the encryption mode, then data is recorded encrypted and when fetching it, it is decrypted
  • Data is not encrypted as true / false
  • One of the strongest encryption types is the aes-256-gcm encryption type we are using

Moving Quick.DB data to ST.db data file

const Database = require('st.db')
const db = new Database(`FileName`)
const quickdb = require("quick.db");

db.moveQuickDB(quickdb)
  • Note! The sql format is converted to json format so that it can be fully stored and used in our data

How do you name the basic folder name to the name you want?

  • Simple example of a method
const Database = require('st.db')
const db = new Database(`guilds`,{
  path: 'FolderName',
})
  • FolderName Enter the name of the folder in which you want to store the files
  • Note : If you don't do this, it will create a folder called ST.db to store the files

Log Mode

  • To know in console everything is added to the data
const Database = require('st.db')
const db = new Database(`FileName`,{
   log: true,
})

Set / Push Functions Examples

var object1 = {name: "Shuruhatik#0001", id: 742070589212327947}
db.set('Profile', object1); /* Profile: {name: "Shuruhatik#0001", id: 742070589212327947} 
*/
var example1 = ['eg', 'ps']
db.set('Array', example1); /* example1: ['eg', 'ps'] */
db.overwrite({name:'Mohamed'}); //It deletes all data and writes the statement you want with the knowledge that it is written directly without adding {}

Fetch / All Functions

db.get('profile'); // Get the value of the data
db.fetch('data'); // Fetches the value of the data
db.all(); // Fetches everything in the database
db.load(); //It makes a load to everything in the data

Remove Functions

db.remove('Array', 'element3'); // Removing something from an array using value/index
db.deleteEach('data'); // Deletes each data that starts with the given parameter

File size Function

db.size() //To find out the size of the data file in byte
db.size('MB')//To find out the size of the data file in ,b
/*Example
console.log(db.size(`MB`))
*/

Boolean Function

db.has('data'); // Returns "true" or "false" if the database has the data or not.

Clear / Destroy Functions

db.clear(); // Clears everything from the database
db.destroy(); // Delete the database file (And Clear All Data)

Maths Functions

  • You must have a registered number in order to perform the calculation
var newEco = db.math("credits", "+", 10); // Adds 10 to the data (without set it), You Can Use [+,-,*,/]
db.set(`credits`, newEco) // set "credits": 5

Multiple Files

  • Example
const Database = require('st.db');

const bot = new Database('bot-config');
const servers = new Database('servers-config');
const users = new Database('users');

servers.set('guilds', '800060636041314375'); // servers-config.st file
bot.set('prefix', '$'); // bot-config.st file
users.set('blacklist_742070589212327947', true); // users.st file

How can I switch data from file to file

  • Example
const Database = require('st.db');

const guilds = new Database('guilds-data');
const users = new Database('users-data');

// switch data from users-data to guilds-data
guilds.transferDB(users)

How to transfer data from file to file ?

  • Example
const Database = require('st.db');

const guilds = new Database('guilds-data');
const users = new Database('users-data');

// Data is transferred from users to guilds
guilds.overwrite(users.load())

System for reading data from one project to another

  • Example
const Database = require('st.db')
const db = new Database(`FileName`,{
  api: true,//If you want to create an API for your data, normal mode it is not enabled
//apipath: 'Memes', If you want to change the filename in the api
})
  • The data you record is stored in your own api, and the api is like that
http://localhost/Filename.st
  • localhost Type in the URL for your project
  • Filename Type the filename without the folder extension and without the json syntax
https://YouName.ProjectName.repl.co/Filename.st
  • Here is an example URL for repl it

How can I read data in another project?

  • Very simply, you are now data that has become an api, which you can read what is in it using the node-fetch package

Any bug or suggestion !

  • Contact With Me Discord: Shuruhatik#0001
  • or Discord Server ST Studio

ST STudio

License