3.1.5 • Published 4 years ago

frost.db v3.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

header

Frost.db

A simple, blazing fast database made for Node.js

So, what is frost.db?

frost.db is a simple, extremely fast and easy to use database, for Node.js. So, is this just another database? Nope, frost.db is completely different and wanted to keep things simple. Icelake is growing day by day and I am working each day trying to make it faster. If you want to help (Please do) Drop a PR! And join our Discord server to get that shiny "contributer" role

Advantages -

  • Extremely easy to use syntax.
  • Very fast and gets data instantly, with only having graceful-fs as its dependency, the package size is tiny
  • Database sizes aren't a single byte more than you put! Awesome!
  • VERY light weight - Have size phobia? Sure! frost.db is perfect for you then!
  • frost.db is NOT a wrapper, and frost.db doesn't need C++ Bindings or Python installed!😀
  • Works perfectly on Repl.it and Glitch :)
  • You can export and import databases anytime, anywhere making switching folders or switching devices a piece of cake! 🍰

Docs -

set(key, value)

Use this to set a key, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

exampledb.set("frost.db", "Very cool :)")

get(key)

Use this to fetch a key from the database, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

// exampledb.set("Cookies", 50)
exampledb.get("Cookies").then(data => {
	console.log(data)
}) // 50

has(key)

Use this to check if a key exists in the database, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

// exampledb.set("Cookies", 50)
exampledb.has("Cookies") // true
// Lets try with a key that doesn't exist in the DB
exampledb.has("Chocolate Cookies") // false

delete(key)

Use this to delete a key from the database, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

// exampledb.set("Cookies", 50)
exampledb.has("Cookies") // true
exampledb.delete("Cookies")
exampledb.has("Cookies") // false

inc(key, optionalamount)

Use this to increment a key, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

// exampledb.set("Cookies", 50)
exampledb.inc("Cookies")
exampledb.get("Cookies") // 51
exampledb.inc("Cookies", 9)
exampledb.get("Cookies") // 60

getAll

Use this to get all the keys in the database in a dictionary format, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

exampledb.set("Cookies", 50)
exampledb.set("Num Num Biscuits", 100)
exampledb.set("Love", "Infinite")

exampledb.getAll().then(console.log) // { "Cookies" : 50, "Num Num Biscuits" : 100, "Love" : "Infinite" }

getAllValues

Use this to get all the keys in the database in a dictionary format, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

exampledb.set("Cookies", 50)
exampledb.set("Num Num Biscuits", 100)
exampledb.set("Love", "Infinite")

exampledb.getAllValues().then(console.log) // [50, 100, "Infinite"]

getAllKeys

Use this to get all the keys in the database in a dictionary format, example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

exampledb.set("Cookies", 50)
exampledb.set("Num Num Biscuits", 100)
exampledb.set("Love", "Infinite")

exampledb.getAllKeys() // ["Cookies", "Num Num Biscuits", "Love"]

showTable

Get the entire DB in a nice little table format (uses console.table), example -

const ice = require("frost.db");
const exampledb = new ice.db("Example");

exampledb.set("Cookies", 50)
exampledb.set("Num Num Biscuits", 100)
exampledb.set("Love", "Infinite")

exampledb.showTable() // { "Cookies" : 50, "Num Num Biscuits" : 100, "Love" : "Infinite" }

table image

startsWith

Get all keys that start with a specific string / int, example -

const ice = require('frost.db');
const exampledb = new ice.db('Example');

exampledb.set("testing", "Henlo!")
exampledb.startsWith("t").then(console.log) // {"testing" : "Henlo!"}

endsWith

Get all keys that end with a specific string / int, example -

const ice = require('frost.db');
const exampledb = new ice.db('example')

exampledb.set('testing', 'Henlo!')

exampledb.endsWith('g').then(console.log) // {"testing": "Henlo!"}

includes

Get all keys that include a specific string / int, example -

const ice = require('frost.db');
const exampledb = new ice.db('example');

exampledb.set('testing', 'Henlo!')

exampledb.includes('i').then(console.log) // {"testing": "Henlo!"}

setAsHash

Set a key's value but hashed. Useful for storing sensitive data like passwords, example -

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.setAsHash('John Doe', 'I love spongebob cartoons', 'SHA256');

setMany

Set multiple keys, example

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.setMany({"Gaming":"Linus", "Fun":"Linus", "Hotel", "Trivago"})

getMany

Gets multiple keys, example

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.getMany(["Gaming", "Fun", "Hotel"]).then(console.log) // ["Linus","Linus","Trivago"]

autoNum

Gets a random number which is NOT in the database. Useful for logs and more, example -

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.autoNum() // 12345

Random

Gets a random key, example -

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.set('1', 1)
exampledb.set('2', 2)
exampledb.set('3', 3)
exampledb.set('4', 4)
exampledb.set('5', 5)

exampledb.random().then(console.log) // 1
exampledb.random().then(console.log) // 5

count

Returns the total amount of keys in the database, example -

const ice = require('frost.db');
const exampledb = new ice.db('testing');

exampledb.set('1', 1)
exampledb.set('2', 2)
exampledb.set('3', 3)
exampledb.set('4', 4)
exampledb.set('5', 5)

exampledb.coubt() // 5
3.1.1

4 years ago

3.1.0

4 years ago

3.1.5

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.1.1

4 years ago

1.0.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago