Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A light-weight Node.js Typescript ORM for MySQL basic CRUD that is database-model-indepedent.
Run TABLE or VIEW creation queries for you.
Allows you to decorate your Typescript class with a MySQL TABLE or VIEW name so you can run basic CRUD operations easily.
npm install --save classql
Say you have a MySQL TABLE or VIEW:
CREATE TABLE USER_ACCOUNTS (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
email VARCHAR(45) NOT NULL,
hashedPassword VARCHAR(100) NOT NULL,
firstName VARCHAR(20) NOT NULL,
lastName VARCHAR(20) NOT NULL
)
import * as classql from 'classql';
@classql.model('USER_ACCOUNTS')
class UserAccount {
id: number;
email: string;
hashedPassword: string;
firstName: string;
lastName: string;
}
// Create MySQL connection:
let db = new classql.Database({
host: 'localhost',
user: 'root',
password: 'root',
database: 'my_database_name'
});
// Or:
let db = new classql.Database('mysql://root:root@localhost/my_database_name?debug=true&timeout=1000000');
/** GET */
// Returns a single object or null:
await db.on(UserAccount).get({ id: 1 });
// Returns an object with any specified field(s) e.g. { email: 'jd@works.io' }
await db.on(UserAccount).get({ id: 1 }, ['email']);
/** GET ALL */
// Returns a list of objects or an empty list:
await db.on(UserAccount).getAll();
await db.on(UserAccount).getAll({ firstName: 'John' });
// To pass offset or limit option:
await db.on(UserAccount).getAll({ limit: 10, offset: 20 });
await db.on(UserAccount).getAll({ firstName: 'John' }, { limit: 10 });
/** DELETE */
// Delete any matched field(s):
await db.on(UserAccount).delete({ id: 5 });
/** CREATE OR UPDATE */
// If no id field exists, this method creates an object.
// Otherewise, it will update an existing tuple.
let account = new UserAccount({
email: 'jd@works.io',
hashedPassword: 'hasedPassword',
firstName: 'John',
lastName: 'Doe'
});
let result = await db.on(UserAccount).save(account);
let id = result.insertId;
/** CREATE ALL OR UPDATE ALL */
// If no id field exists on every object in a list, this method runs INSERT query.
// Otherwise, it will run INSERT and ON DUPLICATE UPDATE.
let items = [
new UserAccount({ ... }), new UserAccount({ ... }), new UserAccount({ ... })
];
await db.on(UserAccount).saveAll(items);
// Alternatively, to enter prepared sql statement just do:
db.query('SELECT * FROM USER_ACCOUNTS WHERE id > 5').then(doSth).catch(doSthElse);
/** COUNT */
// Returns the number of result counted e.g. 12
await db.on(UserAccount).count({ name: 'John' });
FAQs
A light-weight Typescript ORM for MySQL basic CRUD.
The npm package classql receives a total of 0 weekly downloads. As such, classql popularity was classified as not popular.
We found that classql 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.