Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
database-connector-service
Advanced tools
A TypeScript-based service for managing MySQL, MSSQL, and Redis connections.
Esnek ve güçlü bir Node.js veritabanı bağlayıcısı. MySQL ve MSSQL için yerleşik destek, Redis önbellekleme, sorgu oluşturma ve işlem yönetimi özellikleri sunar.
npm install database-connector-service
Proje kök dizininizde bir .env
dosyası oluşturun:
# Veritabanı Yapılandırması
DB_TYPE=mysql # veya mssql
DB_HOST=localhost
DB_USER=your_username
DB_PASSWORD=your_password
DB_DATABASE=your_database
DB_PORT=3306 # MySQL=3306, MSSQL=1433
DB_ENCRYPT=false # MSSQL için
# Redis Yapılandırması (İsteğe bağlı)
REDIS_ENABLED=true
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_TTL=3600
import { createQueryBuilder, query, execute, transaction } from 'database-connector-service';
// 1. Basit Sorgu
const users = await query(
'SELECT * FROM users WHERE active = ?',
[true]
);
// 2. Önbellekli
const cachedUsers = await query(
'SELECT * FROM users WHERE active = ?',
[true],
{
cache: {
key: 'active-users',
ttl: 3600
}
}
);
// 3. Sayfalama
const { data, pagination } = await queryWithPagination(
'SELECT * FROM users WHERE active = ?',
[true],
{
page: 1,
pageSize: 10,
orderBy: 'name',
direction: 'ASC'
}
);
// İşlem örneği
await transaction(async (trx) => {
await trx.query('INSERT INTO users (name) VALUES (?)', ['John']);
await trx.query('UPDATE stats SET total = total + 1');
});
const users = createQueryBuilder('users');
// SELECT örneği
const activeUsers = await users
.select()
.select('id', 'name', 'email')
.where('status', '=', 'active')
.leftJoin('orders', 'users.id = orders.user_id')
.groupBy('role')
.having('COUNT(*) > 5')
.orderBy('created_at', 'DESC')
.cache('active-users', 3600)
.execute<User>();
// INSERT örneği
await users
.insert()
.values({
name: 'John',
email: 'john@example.com'
})
.invalidateCache('users', 'stats')
.execute();
// UPDATE örneği
await users
.update()
.set({
status: 'inactive',
updated_at: new Date()
})
.where('id', '=', 1)
.invalidateCache('users')
.execute();
// DELETE örneği
await users
.delete()
.where('status', '=', 'inactive')
.invalidateCache('users', 'stats')
.execute();
// Transaction örneği
await users.transaction(async (trx) => {
await users
.insert()
.values({ name: 'John' })
.execute();
await users
.update()
.set({ total: 100 })
.where('type', '=', 'user')
.execute();
});
// Pagination örneği
const { data, pagination } = await users
.select()
.where('active', '=', true)
.orderBy('name')
.paginate<User>({ page: 1, pageSize: 20 });
// 1. Sorgu Oluşturucu ile Önbellekleme
const users = createQueryBuilder('users');
const users = await createQueryBuilder('users')
.select()
.where('status', '=', 'active')
.cache('active-users', 3600)
.execute<User>();
// 2. Çoklu Önbellek Desenlerini İnvalidasyon
await invalidateCache(['users', 'orders', 'stats']);
// 3. Otomatik Önbellek İnvalidasyonu
await execute(
'INSERT INTO users (name) VALUES (?)',
['John'],
['users', 'user_stats'] // invalidasyon için önbellek desenleri
);
// İşlem Örneği
await transaction(async (trx) => {
// Kullanıcı ekle
const [user] = await trx.query(
'INSERT INTO users (name) VALUES (?) RETURNING id',
['John']
);
// Kullanıcı ID'sini kullanarak profil ekle
await trx.query(
'INSERT INTO profiles (user_id, bio) VALUES (?, ?)',
[user.id, 'New user bio']
);
// İstatistikleri güncelle
await trx.query(
'UPDATE user_stats SET total = total + 1'
);
});
Katkılarınızı bekliyoruz! Lütfen Pull Request göndermekten çekinmeyin.
MIT
FAQs
A TypeScript-based service for managing MySQL, MSSQL, and Redis connections.
We found that database-connector-service 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.