Back to list
paralect

hive-handler

by paralect

0🍴 0📅 Jan 18, 2026

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

EventPayloadTrigger
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.update for silent bulk updates (no events)
  • Use ifUpdated helper to filter field changes

Score

Total Score

50/100

Based on repository quality metrics

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

Reviews

💬

Reviews coming soon