
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
ts-query-model
Advanced tools
Simple TS wrapper for database queries with some convenience features. Works with MySQL, PostgreSQL and SQLite.
A simple TypeScript wrapper for database queries with some convenience features. Not an ORM. Currently supports MySQL, PostgreSQL and SQLite.
It aims to provide a middle ground between the complexity of using an ORM and having to manually create types for raw SQL queries.
➡️➡️ Full API documentation ⬅️⬅️
npm install ts-query-model
To use with MySQL, use the mysql2 package:
npm install mysql2
To use with PostgreSQL, use the pg package:
npm install pg
To use with SQLite, use the sqlite3 package:
npm install sqlite3
It is recommended to use in conjunction with sql-template-strings
npm install sql-template-strings
import { columns, Database } from "ts-query-model";
import MySQLConnection from "ts-query-model/mysql";
import SQL from "sql-template-strings";
// Step 1: define your database connection
// (Also supports SQLite and PostgreSQL)
const db = new Database(
new MySQLConnection({
uri: "mysql://your-database-connection-string",
})
);
// Step 2: create a query
const getUsers = db.getMany({
name: "get-all-users", // optional query name for logging
columns: {
// define the columns to be returned
id: columns.numberAutoIncrement(),
name: columns.string(),
dateCreated: columns.date(),
isBanned: columns.booleanInt(),
},
query: ({ limit }: { limit: number }) =>
// function to return the SQL to be executed
SQL`SELECT id, name, dateCreated, isBanned FROM users LIMIT ${limit}`,
});
// Step 3: execute your query
const result = await getUsers({ limit: 10 });
// ^ result is correctly ^ query arguments are
// typed according to correctly typed
// your columns
See more at the full API documentation
FAQs
Simple TS wrapper for database queries with some convenience features. Works with MySQL, PostgreSQL and SQLite.
We found that ts-query-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.