The opposite of the .add method. Instead of adding to the value of that key, it subtracts. No need of examples as you can imagine.
.push(key, value)
Pushes a value on the array of that key. If that key does not exist, it will create one with an array and the value inside already. If that key exists and there is an array, it will push into that array and if that key exists but it's value is not an array, it will simply not push.
constdb=require("lol.db")()db.push('thiskeydoesnotexist',100)console.log(db.get('thiskeydoesnotexist')) // returns [100]db.push('thiskeydoesnotexist',100)console.log(db.get('thiskeydoesnotexist')) // returns [100,100]// As all of the methods above, it supports objects.
.removeFromArray(key, value)
Title says it all, removes the value from the key's array.
constdb=require("lol.db")()db.set('thiskeydoesnotexist',100)console.log(db.get('thiskeydoesnotexist')) // returns 100db.delete('thiskeydoesnotexist')console.log(db.get('thiskeydoesnotexist')) // returns undefined because that key does not exist anymore
.clear()
Be carefull about this method, it clears the ENTIRE database. Not just a key. But the ENTIRE database.
constdb=require("lol.db")()db.set('thiskeyexists',100)db.set('thiskeyexists2',300)db.set('anotherkey',200)/* The entire database will look like:{"thiskeyexists":100,"thiskeyexists2":300,"anotherkey":200}*/db.clear()/* The database now looks like... {}*/
.size(beautify)
Returns the total size of the database (in BYTES). However, you can set the parameter beautify to true and it will return a converted amount of bytes to whatever it is.
Returns the quantity of MAIN keys on the database.
constdb=require("lol.db")()/* Imagine that your data looks like: {"mykey":"something","anotherkey":"somethingelse"}*/console.log(db.keys()) // returns 2 (because there are 2 keys in the database. Keys inside objects inside keys though DO NOT count)
.setAll(data)
sets the entire database to one single JSON object.
constdb=require("lol.db")()db.setAll({ firstkey:"my data", secondkey:"more data" })console.log(db.raw.d) // returns the ENTIRE database, so it will return { firstkey: "my data", secondkey: "more data" }
.raw | Raw Functions And Parameters
This seccion is basically raw functions that we used to build some major functions like set, delete or get. The object looks like this btw:
{"data":"entire database data","d":"same as data, but it's a cool shortcut","assign":"THIS IS A FUNCTION AND IT IS USED TO SET NESTED KEYS TO OBJECTS (or normal keys too ig).","deletePath":"The opposite of assign, it's still a function, HOWEVER it DELETES the keys.","path":"The path for your database file","size":"This will be a number and it represents the size of your database","exists":"true or false (if the database exists)"}
btw this is implemented in the database, so once you defined the database, you will have access to this object doing db.raw.nameofthekeyabove