← スキル一覧に戻る

hive-database
by paralect
⭐ 0🍴 0📅 2026年1月18日
SKILL.md
name: hive-database description: Database operations in Hive framework globs:
- src/**/*.js alwaysApply: false
Database Operations
Access Service
import db from 'db';
const taskService = db.services.tasks; // From schema name
Find Operations
// Find many
const { results, pagesCount, count } = await service.find(
{ status: 'active' },
{ page: 1, perPage: 20, sort: '-createdOn', fields: ['_id', 'title'] }
);
// Find one
const doc = await service.findOne({ _id: id });
// Check exists
const exists = await service.exists({ _id: id });
// Count
const total = await service.count({ status: 'active' });
// Distinct values
const statuses = await service.distinct('status');
// Aggregate
const { results } = await service.aggregate([
{ $match: { status: 'done' } },
{ $group: { _id: '$project._id', count: { $sum: 1 } } },
]);
Write Operations
// Create
const doc = await service.create({ title: 'New', user: ctx.state.user });
// Update one (must use function)
const updated = await service.updateOne(
{ _id: id },
(doc) => ({ ...doc, title: 'Updated' })
);
// Update many
await service.updateMany(
{ status: 'pending' },
(doc) => ({ ...doc, status: 'active' })
);
// Remove
await service.remove({ _id: id });
// Generate ID
const newId = service.generateId();
Atomic Operations (No Events)
// Silent bulk update
await service.atomic.update(
{ 'project._id': projectId },
{ $set: { 'project.name': newName } },
{ multi: true }
);
Query Patterns
import { when } from 'services/utils';
const { results } = await service.find({
// Conditional fields
...when(status, { status }),
...when(userId, { 'user._id': userId }),
// Complex conditions
status: { $in: ['active', 'pending'] },
createdOn: { $gte: startDate, $lt: endDate },
$or: [{ 'user._id': id }, { isPublic: true }],
});
Rules
updateOnerequires a function, not an object- Use
atomic.updatefor bulk/silent updates - Use
when()helper for conditional query building
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です