README
What is ST.db?
- It is a quick and easy storage unit that relies on
maps
to store data in JSON and YAML formats
What are the features of maps in the database?
- A
Map
does not contain any keys by default. It only contains what is explicitly put into it. - A
Map
's keys can be any value (including functions, objects, or any primitive). - The keys in
Map
are ordered in a simple, straightforward way: AMap
object iterates entries, keys, and values in the order of entry insertion. - Performs better in scenarios involving frequent additions and removals of key-value pairs.
- A
Map
is an iterable, so it can be directly iterated.
Features
- It contains valuable and useful methods
- Strong intelligence in reading, recording and analyzing data
- Simple and Easy To get started
- It stores data in the form of maps
- Multiple JSON or YAML Files
- There are more than one mode and you can switch between them
- can I switch data from file to file
- Supports data encryption mode which enables you to encrypt data
- Supports data encryption mode if you want it
- Methods are strict
- Supports moving Quick.DB data to ST.db data file
- System for reading data from one project to another
- Increase in performance and increase in reading and writing
- Supports filters
- Data encryption with custom password
Content
- Installing
- What is ST.db?
- Features
- Events
- Methods
- Sets a value to the specified key on the database
- Fetches the data from database!
- Fetches everything and sorts by given target
- Set, get, delete and control the array in the database
- Deletes a key from the database!
- Delete's all of the data from the database!
- Returns everything from the database
- Does a math calculation and stores the value in the database!
- Checks if there is a data stored with the given key
- Convert old ST.db from object to map
- Return's the value type of the key!
- Find out the size of the database file
- Encrypt and decrypt a value of the same type
- Reload the data in the database
- Example usage
Getting Started
Installation
You can start install the package on your project:
npm install st.db
yarn add st.db
pnpm add st.db
- CommonJS
const Database = require('st.db')
- ESM
import Database from 'st.db';
Then Start define it like this:
- Example :
JSON

const db = new Database({path:'FileName.json'})//You can write the name you want
- Example :
YAML

const db = new Database({path:'FileName.yml'})//You can write the name you want
Important Notes
- Note that you can write the file extension or you can write the file name without the extension and in both cases it will be recognized from the data easily
- If the file dosen't exist, it will create it
- In the event that you store more than 50 objects per millisecond, it is recommended to use
await
before any action- Example to prevent pressure, if there is pressure or without pressure, you can use it
// set
await db.set({ key:'Array', value:['eg', 'ps'] });
// get
console.log(await db.get({key:'Array'}))
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({
path:'FileName.json',
encryption: {
password:"shuruhatik"
//digest:"sha512"// one of: 'blake2b512' | 'blake2s256' | 'md4' | 'md5' | 'md5-sha1' | 'mdc2' | 'ripemd160' | 'sha1' | 'sha224' | 'sha256' | 'sha3-224' | 'sha3-256' | 'sha3-384' | 'sha3-512' | 'sha384' | 'sha512' | 'sha512-224' | 'sha512-256' | 'sm3' | 'whirlpool';
}
})
// or
const db = new Database({
path:'FileName.json',
encryption: true
})
Notes for encryption mode
- Note in the event that you do not activate the encryption feature, the data will be recorded directly unencrypted, and when you activate the encryption mode, the data will be encrypted when recording
password
It is an important thing in the event that you forgot the password or changed the password, the data recorded with this password could not be read and you must set the correct password- Supports object and array encrypting now
- If you do not enter a specific password, the default password will be
st.db
Moving Quick.DB data to ST.db data file
const Database = require('st.db')
const db = new Database({path:'FileName.yml'})
const quickdb = require("quick.db");
db.importFromQuickDB(quickdb)
Note!
The sql format is converted to json format so that it can be fully stored and used in our data
Debug Mode
- To know in console everything is added to the data
const Database = require('st.db')
const db = new Database({
path:'FileName.json',
debug: true
})

Multiple Files
- Example
const Database = require('st.db');
const bot = new Database({path:'bot.json'});
const servers = new Database({path:'servers.json'});
const users = new Database({path:'users.json'});
servers.set({
key: 'guilds',
value: '800060636041314375'
});
bot.set({
key:'prefix',
value: '