
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600× Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
async-db-adapter
Advanced tools
Async database adapter for Javascript(& Typescript).
npm install async-db-adapter --save
You can create as follows:
(Please refer to the Config section for config.)
const connection = require("async-db-adapter").create({
adapter: "mysql"
/* config */
})
// or import {create} from "async-db-adapter"
// create(/* ... */)
npm install mysql --save
)npm install mysql2 --save
)npm install pg --save
)npm install sqlite3 --save
)Use adapter
, pool
parameter of create
function`s config
const connection = create({
adapter: "mysql",
...mysqlConfig,
}) // return instanceof MysqlConnection
const connection = create({
adapter: "mysql",
pool: true,
...mysqlConfig,
}) // return instanceof MysqlPool
const connection = create({
adapter: "mysql2",
...mysqlConfig,
}) // return instanceof Mysql2Connection
const connection = create({
adapter: "mysql2",
pool: true,
...mysqlConfig,
}) // return instanceof Mysql2Pool
const connection = create({
adapter: "pg",
...pgConfig,
}) // return instanceof PgConnection
const connection = create({
adapter: "pg",
pool: true,
...pgConfig,
}) // return instanceof PgPool
const connection = create({
adapter: "sqlite3",
filename: ":memory:",
}) // return instanceof Sqlite3Connection
const connections = create([
{
adapter: "mysql2",
pool: true,
...mysqlConfig,
},
{
adapter: "pg",
pool: true,
...pgConfig,
},
{
adapter: "sqlite3",
filename: ":memory:",
},
]) // return instanceof [MysqlPool, PgPool, Sqlite3Connection]
const connections = create({
default: {
adapter: "mysql2",
pool: true,
...mysqlConfig,
},
pg: {
adapter: "pg",
pool: true,
...pgConfig,
},
sqlite: {
adapter: "sqlite3",
filename: ":memory:",
},
}) // return instanceof {default: MysqlPool, pg: PgPool, sqlite: Sqlite3Connection}
All adapter objects inherit the following interfaces:
type TransactionHandler<P> = (connection: Connection) => Promise<P>|P
// mysql-pool, mysql2-pool, pg-pool
interface Pool extends Connection {
getConnection(): Promise<Connection>
}
// mysql, mysql2, pg, sqlite3
interface Connection {
close(): Promise<void>
query(query: string, values?: any): Promise<any>
select(query: string, values?: any): Promise<Row[]>
first(query: string, values?: any): Promise<Row|undefined>
transaction<P>(handler: TransactionHandler<P>): Promise<P>
}
Config can be defined as follows:
Use the connection option of the mysql
or mysql2
.
interface MysqlConnectionConfig extends MysqlBaseConfig {
readonly adapter: "mysql" | "mysql2"
readonly pool?: false
}
interface MysqlPoolConfig extends MysqlBaseConfig {
readonly adapter: "mysql" | "mysql2"
readonly pool: true
acquireTimeout?: number
waitForConnections?: boolean
connectionLimit?: number
queueLimit?: number
}
interface MysqlBaseConfig {
host?: string
port?: number
user?: string
password?: string
database?: string
charset?: string
timeout?: number
localAddress?: string
socketPath?: string
timezone?: string
connectTimeout?: number
stringifyObjects?: boolean
insecureAuth?: boolean
supportBigNumbers?: boolean
bigNumberStrings?: boolean
dateStrings?: boolean
trace?: boolean
multipleStatements?: boolean
flags?: string[]
queryFormat?(query: string, values: any): void
}
Use the connection option of the pg
.
interface PgConnectionConfig extends PgBaseConfig {
readonly adapter: "pg"
readonly pool?: false
}
interface PgPoolConfig extends PgBaseConfig {
readonly adapter: "pg"
readonly pool: true
max?: number
min?: number
connectionTimeoutMillis?: number
idleTimeoutMillis?: number
application_name?: string
Promise?: PromiseConstructorLike
}
interface PgBaseConfig {
ssl?: boolean | tls.TlsOptions
user?: string
database?: string
password?: string
port?: number
host?: string
connectionString?: string
keepAlive?: boolean
stream?: stream.Duplex
}
Use the connection option of the sqlite3
.
interface Sqlite3ConnectionConfig {
readonly adapter: "sqlite3"
readonly pool?: false
filename: string
mode?: number
}
MIT
FAQs
Async database adapter for Javascript(& Typescript).
The npm package async-db-adapter receives a total of 2 weekly downloads. As such, async-db-adapter popularity was classified as not popular.
We found that async-db-adapter 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
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.