Awesome-omni-skill hive-database

Database operations in Hive framework

install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/backend/hive-database" ~/.claude/skills/diegosouzapw-awesome-omni-skill-hive-database && rm -rf "$T"
manifest: skills/backend/hive-database/SKILL.md
source content

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

  • updateOne
    requires a function, not an object
  • Use
    atomic.update
    for bulk/silent updates
  • Use
    when()
    helper for conditional query building