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
- 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@latestYou can update to a newer version to receive updates using npm.
npm update st.dbThen Start define it like this:
const Database = require('st.db')
const db = new Database('FileName')//You can write the name you wantImportant 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

- 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
encryptedand when fetching it, it isdecrypted - Data is not encrypted as
true/false - One of the strongest encryption types is the
aes-256-gcmencryption 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',
})FolderNameEnter 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 dataRemove Functions
db.remove('Array', 'element3'); // Removing something from an array using value/index
db.deleteEach('data'); // Deletes each data that starts with the given parameterFile 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": 5Multiple 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 fileHow 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.stlocalhostType in the URL for your projectFilenameType 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-fetchpackage
Any bug or suggestion !
- Contact With Me Discord: Shuruhatik#0001
- or Discord Server ST Studio
