
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
mapped-sqlite3
Advanced tools
The library that allows you to work with SQLite3 like with Maps. (key/value).
The library that allows you to work with SQLite3 like with Maps. (key/value).
Installing:
npm i mapped-sqlite3 --save
const MappedSQLite3 = require("mapped-sqlite3");
const db = new MappedSQLite3("./db.sqlite");
db.createTable("Testing").then(async () => {
let table = db.table("Testing");
await table.set("Key", 1 + 1);
console.log(await table.get("Key")); // 2
console.log(await table.all()); // { Key: 2 }
// Will set multiple columns.
await table.setSeveral({
a: 1, // number
b: "Hello, world!", // string
c: true, // boolean
e: undefined, // undefined
f: {a: 5}, // object
g: [1, 2, 3] // object
});
console.log(await table.all()); // { ... }
console.log(await table.filter(i => typeof (i) === "number")); // { Key: 2, a: 1 }
console.log(await table.find(i => typeof (i) === "string" && i.startsWith("Hello"))); // "Hello, world!"
await table.remove("c"); // c - true
console.log(await table.get("c")); // null
console.log((await table.get("g"))[0]); // 1
await table.clear();
await table.set("a", 1);
await table.set("b", 3);
await table.set("c", 2);
console.log(await table.all()); // { a: 1, b: 3, c: 2 }
console.log(await table.sort((a, b) => a[1] - b[1])); // { a: 1, c: 2, b: 3 }
await db.renameTable("Testing", "Testing2");
table = db.table("Testing2");
console.log(await table.all()); // { a: 1, b: 3, c: 2 }
await db.filterTable("Testing2", i => i <= 1);
console.log(await table.all()); // { a: 1 }
await db.dropTable("Testing2");
});
To start using mapped-sqlite3 you need to create new database file (Just empy file with .db or .sqlite extension).
You can use already created databases, but make sure that you're not using mapped-sqlite3 API in already created table.
You can save string, number, object/array, boolean, undefined data types. null and NaN is not supported and NaN will be converted to "NaN" (string) and null will be converted to undefined. Functions are not supported too.
When mapped-sqlite3 creates new table it has key, value and type rows.
All Database API is asynchronous and returns Promises, so you'll need to use .then or async/await.
You can acess sqlite3 database class with this.db and path to database with this.path.
All examples are in async function.
Creates new table in database.
await db.createTable("test");
Deletes (drops) table in database.
await db.dropTable("test");
Renames table in database.
await db.renameTable("test", "test2");
Filters table. (If func returns true it won't be deleted).
// will delete all variables that are not string.
db.filterTable("test", row => typeof(row) === "string");
Generates table object.
await db.createTable("test");
const table = await db.table("test"); // { get: ..., ... }
Note: // table - {...} is just visual representation of real table.
Gets value by key.
Note: Read Information above to get info about supported types.
// table - { a: 1 }
await table.get("a"); // 1
Sets value by key.
// table - {}
await table.set("a", 1);
// table - { a: 1 }
Sets all key/values in object into table.
// table - {}
await table.setSeveral({
a: 1,
b: "Hello, world!"
});
// table - { a: 1, b: "Hello, world!" }
Gets all key/values from table.
await table.all(); // {...}
Gets all key/values that passed filter check.
// table - { a: 1, b: "Hi", c: true }
await table.filter(i => i === 1); // { a: 1 }
Gets first key/value that passed filter check.
// table - { a: {x:1}, b: {x:2}, c: {x:3} }
await table.find(i => i.x === 2); // { x: 2 }
Returns sorted table.
func should pass 2 arguments - a and b. a and b is arrays that contains key and value - [0] element is key, [1] element is value.
Note: Learn about sorting here - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort.
// table - { a: 1, b: 3, c: 2 }
await table.sort((a, b) => a[1] - b[1]); // { a: 1, c: 2, b: 3 }
Removes column by key.
// table - { test: 1 }
await table.remove("test");
// table - {}
Deletes all columns in table.
// table - { a: 1, b: 2 }
await table.clear();
// table - {}
MIT
FAQs
The library that allows you to work with SQLite3 like with Maps. (key/value).
The npm package mapped-sqlite3 receives a total of 0 weekly downloads. As such, mapped-sqlite3 popularity was classified as not popular.
We found that mapped-sqlite3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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
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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.