
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
localstorage-db-js
Advanced tools
  var StdS = new localDb("Students");
In this example it creates a database named "Students", and this database will be accessed by the StdS variable. If the database stored any data previously by this name( "Students" ) in localStorage, the previous data will still be available.
var StdS = new localDb("Students","new");
Creates a new database, Previous data will be deleted.
insVal()StdS.insVal( // insert data as multiple objects
{name:"Abinash",age:19,roll:10},
{name:"Ram",age:20,roll:11},
{name:"Sujan",age:21,roll:12},
{name:"Pithu",age:22,roll:13}
);
StdS.insVal( // insert data as multiple objects
{"name":"Abinash","age":19,"roll no":10},
{"name":"Ram","age":20,"roll no":11},
{"name":"Sujan","age":21,"roll no":12},
{"name":"Pithu","age":22,"roll no":13}
); // if you want to use multi word keys, you have to quote them (Concept of js objects)
Inserts all data as javascript objects in Students database.
var data = [
{name:"Abinash",age:19,roll:10},
{name:"Ram",age:20,roll:11},
{name:"Sujan",age:21,roll:12},
{name:"Pithu",age:22,roll:13}
];
StdS.insVal(data);
// insert data as array of objects
Insert as array of objects. Here data is a array of objects.
get()var allData = StdS.get();
// All data will be stored in the allData variable
console.log(allData);
var std = StdS.get(5);
// Returns the 5 indexed element.
var x = StdS.get(5,"first");
// Returns first 5 elements
var x = StdS.get(10,"last");
// Returns last 10 elements
var sujan20 = StdS.get("name=='Sujan' && age>20");
// Get from all elements where condition is true
var x = StdS.get(5,"name=='Abinash'");
// Get total 5 elements from first where condition is true
var x = StdS.get(5,"name=='Abinash'","last");
// Get total 5 elements from last where condition is true
var x = StdS.get(7,"name=='Abinash'","first");
// Get total 7 elements from first where condition is true
var x = StdS.get(5,"last","name=='Abinash'");
// Get total 5 elements from last where condition is true
var x = StdS.get(7,"first","name=='Abinash'");
// Get total 7 elements from first where condition is true
Results are always stored as array of objects
set()StdS.set("name='Ks'",2);
// Set name='Ks' of the second element and returns 1
//dbName.set(apply,condition)
StdS.set("name='K'","name=='Abinash' && age>20");
//Changes in all elements by condition and returns number of updated elements
StdS.set("name='S'","roll==25",10);
// checks first 10 elements, and updates where condition is true
StdS.set("age=25","name=='Abinash'","last",10);
// checks last 10 elements and updates where conditions is true
StdS.set("age=25","name=='Abinash'","first",20);
// checks first 20 elements and updates where conditions is true
StdS.set("age=25","name=='Abinash'",20,"first");
// checks first 20 elements and updates where conditions is true
StdS.set("age=25","name=='Abinash'",10,"last");
// checks last 10 elements and updates where conditions is true
set()always returns how many elements are updated
del() | delAll() | delDb()StdS.delAll(); //Deletes all data in the database
StdS.del(5); //Deletes the 5 indexed (6th) element
StdS.del(2,"first");
//Deletes first 2 elements without any condition
StdS.del(3,"last");
//Deletes last 3 elements without any condition
StdS.del("name=='Ram' && age>=25");
// Delete where name is 'Ram' and age>=25 from all data
StdS.del(3,"last","name=='Abinash'");
StdS.del(3,"name=='Abinash'","last");
// delete where name is 'Abinash, from last 3 elements
StdS.del(3,"first","name=='Abinash'");
StdS.del(3,"name=='Abinash'","first");
// delete where name is 'Abinash, from first 3 elements
StdS.delDb(); // Deletes the database and it's all data
Delete functions always returns how many data are deleted
sort()
sort()returns the localDb object after sorting
StdS.sort("age");
//sort() returns the localDb object after sorting
//Sorts all data in ascending order
StdS.sort("name");
// OR
StdS.sort("name","aSC");// the second argument is case insensitive
// OR
StdS.sort("name","ascending");
// Get the same result, Sorts ascending
StdS.sort("name","deS");
StdS.sort("name","dEscenDing");
// Sorts Descending
var y = StdS.sort("age").get(0);
//Get the 1st element after sorting
//Means the element with smallest age value
//Or this can also be done
StdS.sort("age");
var y = StdS.get(0);
//Get Same Result
var y = StdS.sort("age","des").get(0);
//Get the 1st element after sorting
//Means the element with maximum age value
If you save() after sorting, the sorted Database will be saved in localStorage
StdS.sort("name").save();
// OR
StdS.sort("name");
StdS.save(); // Save all sorted data
You can "Sort after a Sorting" in a single line.
var y = StdS.sort("age","des").sort("name","asc");
// First sorts by age and then by name
getName()var x = StdS.getName(); // Returns the name of the database
console.log(x);
getKeyName()It will return a string, all data is saved by this string(Name) in the localStorage.
var x = StdS.getKeyName();
console.log(x); // "lDark#4s5dStudentskey2sd55"
setName()var d = StdS.setName("D");
// Changes the name of the database and returns the changed database
console.log(d.get());
// This can also be done
StdS.setName("D");
// All data will be copied to "D" and the StdS database will be deleted
var d = new localDb("D");
console.log(d.get());
length()console.log(d.length());
// Returns the number of elements in the Database
copy()var s = new localDb("myDb");
s.copy(a);
// now s has the all values of a and previous s
s.delAll(); // Deletes everything is s
s.copy(a,b,c); // stores data of a,b,c into s
console.log(s.get());
// Output will be all of the data of a, b, c
localStorage, so we can store up to 5MB data here. Well, think, you are using this DataBase in frontend, so you will have to store one(maybe 2 or 3) user's data. To store this little amount of data, 5MB storage is enough.It may be used in all web applications like offline web applications or PWA or in a normal website.
For Example,
localStorage. Here you have to use a library to store all notes data otherwise you have to write very very long code.FAQs
  
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.