Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
RDSDB is a simple database using node.js and promise-mysql that allows you to 'build' your own sql statements.
$ npm i -g rdsdb
First, we will just connect our db. You can use all the connection options as promise-mysql.
const { RDSDB } = require("../rdsdb.js")
require('dotenv').config() // only used for process.env, not strictly required.
const exampleDB = new RDSDB.Builder({
host: process.env.DB_HOST,
port: 3306,
database: process.env.TEST_DB,
user: process.env.TEST_DB_USERNAME,
password: process.env.TEST_DB_PASSWORD,
table: process.env.TEST_TABLE,
supportBigNumbers: true,
reconnect: true
});
The builder contains 7 different functions to build a query.
insertInto()
adds INSERT INTO ${table}
to the statement.update()
adds UPDATE ${table}
to the statement.listWithParenthesis(any[])
adds a list, for ex. (one, two, three)
valuesList(any[])
adds a string list, for ex. (`one`, `two`, `three`)
setValue(key, value)
adds a key with a value, for ex. one = `1`
where(key, value)
is the same assetValue()
, but use this for where clauses insteadaddStatement(string)
adds whatever you put in on to the end of the statement.At the very end, just call .exec()
to run your query.
This does return a Promise
Some examples of simple queries are:
exampleDB.insertInto().valuesList([`test`, `wow`])
test
and test2
given preset id
and secondid
testDB.update().setValue(`test`, 1).setValue(`test2`, true).where(`id`, 47283).where(`secondid`, 582356763)
A full file could look like:
const { RDSDB } = require("rdsdb")
require('dotenv').config()
const testDB = new RDSDB.Builder({
host: process.env.TEST_HOST,
port: 3306,
database: process.env.TEST_DB,
user: process.env.TEST_DB_USERNAME,
password: process.env.TEST_DB_PASSWORD,
table: process.env.TEST_TABLE,
supportBigNumbers: true,
reconnect: true
});
async function test() {
await testDB.ensureConnection();
// testDB.insertInto().valuesList([`test`, `wow`])
testDB.update().setValue(`test`, 1).setValue(`test2`, true).where(`id`, 47283).where(`secondid`, 582356763)
await testDB.exec().catch((err) => {
console.error(err)
})
}
test();
FAQs
Lightweight API to use in conjunction with MySQL. Built on promise-mysql
We found that rdsdb 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.