← スキル一覧に戻る

hive-handler
by paralect
⭐ 0🍴 0📅 2026年1月18日
SKILL.md
name: hive-handler description: How to create event handlers in Hive framework globs:
- src/resources/**/handlers/*.js alwaysApply: false
Creating Event Handlers
Handlers react to database events automatically.
Location: /src/resources/{name}/handlers/{handlerName}.js
Template
import db from 'db';
const myService = db.services.myResource;
myService.on('created', async ({ doc }) => {
// Handle creation
});
myService.on('updated', async ({ doc, prevDoc }) => {
// Handle update
});
myService.on('removed', async ({ doc }) => {
// Handle removal
});
Events
| Event | Payload | Trigger |
|---|---|---|
created | { doc } | After service.create() |
updated | { doc, prevDoc } | After service.updateOne/Many() |
removed | { doc } | After service.remove() |
Common Patterns
Create related record:
taskService.on('created', async ({ doc }) => {
await eventService.create({
type: 'task.created',
data: { task: doc },
project: doc.project,
});
});
Update parent on child change:
docService.on('created', async ({ doc }) => {
if (doc.role === 'case-study') {
await projectService.updateOne(
{ _id: doc.project._id },
(p) => ({ ...p, caseStudy: doc })
);
}
});
React to specific field change:
import ifUpdated from 'helpers/db/ifUpdated';
taskService.on('updated', ifUpdated(['status'], async ({ doc, prevDoc }) => {
// Only runs when status changed
}));
Cleanup on delete:
docService.on('removed', async ({ doc }) => {
await eventService.remove({ 'data.doc._id': doc._id });
});
Rules
- Keep handlers fast (don't block response)
- Use
atomic.updatefor silent bulk updates (no events) - Use
ifUpdatedhelper to filter field changes
スコア
総合スコア
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
レビュー
💬
レビュー機能は近日公開予定です