
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
accel-record
Advanced tools
Accel Record is a type-safe and synchronous ORM for TypeScript. It adopts the Active Record pattern and is heavily influenced by Ruby on Rails' Active Record.
Accel Record is a type-safe and synchronous ORM for TypeScript. It adopts the Active Record pattern and is heavily influenced by Ruby on Rails' Active Record.
It uses Prisma for schema management and migration, and you can also use existing Prisma schemas as is.
It supports MySQL and SQLite and is currently in alpha version.
For example, if you define a User model like this:
// prisma/schema.prisma
model User {
id Int @id @default(autoincrement())
firstName String
lastName String
age Int?
}
You can write domain logic as follows:
// src/index.ts
import { User } from "./models/index.js";
const user: User = User.create({
firstName: "John",
lastName: "Doe",
});
user.update({
age: 26,
});
for (const user of User.all()) {
console.log(user.firstName);
}
const john: User | undefined = User.findBy({
firstName: "John",
lastName: "Doe",
});
john.delete();
You can also extend models and define custom methods as you like.
// src/models/user.ts
import { ApplicationRecord } from "./applicationRecord.js";
class UserModel extends ApplicationRecord {
// Define a method to get the full name
get fullName(): string {
return `${this.firstName} ${this.lastName}`;
}
}
// src/index.ts
import { User } from "./models/index.js";
const user = User.create({
firstName: "John",
lastName: "Doe",
});
console.log(user.fullName); // => "John Doe"
Install the npm package:
npm install accel-record
Install a database driver:
for MySQL or MariaDB
npm install mysql2
for SQLite
npm install better-sqlite3
Here is an example for MySQL.
$ npm install accel-record mysql2
$ npx prisma init
By defining the Prisma schema as shown below and calling initAccelRecord
, you can connect to the database.
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
generator custom_generator {
provider = "prisma-generator-accel-record"
output = "../src/models"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
firstName String
lastName String
age Int?
}
// src/index.ts
import { initAccelRecord } from "accel-record";
import { User } from "./models/index.js";
initAccelRecord({
type: "mysql",
datasourceUrl: process.env.DATABASE_URL,
}).then(() => {
User.create({
firstName: "John",
lastName: "Doe",
});
console.log(`New user created! User.count is ${User.count()}`);
});
$ export DATABASE_URL="mysql://root:@localhost:3306/accel_test"
$ npx prisma migrate dev
# Example of executing .ts files using tsx
$ npm i -D tsx
$ npx tsx src/index.ts
New user created! User.count is 1
FAQs
Accel Record is a type-safe and synchronous ORM for TypeScript. It adopts the Active Record pattern and is heavily influenced by Ruby on Rails' Active Record.
The npm package accel-record receives a total of 18 weekly downloads. As such, accel-record popularity was classified as not popular.
We found that accel-record demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.