# Hive Mapping

> Schema mappings for auto-syncing embedded documents

- Skill: `diegosouzapw/hive-mapping` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add diegosouzapw/hive-mapping`
- Raw SKILL.md: https://api.skillmd.com/api/skills/diegosouzapw/hive-mapping/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: diegosouzapw (https://skillmd.com/u/diegosouzapw)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/diegosouzapw/hive-mapping

---


# Schema Mappings

Auto-sync embedded references when source documents change.

Location: `/src/autoMap/schemaMappings.json`

## How It Works

1. You embed document references in schemas (e.g., `user: { _id, fullName }`)
2. You register the mapping in `schemaMappings.json`
3. When source document updates, all referencing documents sync automatically

## Config Format

```json
{
  "tasks": {
    "user": {
      "schema": "users"
    },
    "project": {
      "schema": "projects"
    }
  }
}
```

Means: In `tasks` collection, fields `user` and `project` reference `users` and `projects` collections.

## Example

**Schema with embedded reference:**
```javascript
// tasks.schema.js
project: z
  .object({
    _id: z.string(),
    name: z.coerce.string().nullable().optional(),
    logoUrl: z.coerce.string().nullable().optional(),
  })
  .nullable()
  .optional(),
```

**Mapping config:**
```json
{
  "tasks": {
    "project": {
      "schema": "projects"
    }
  }
}
```

**Result:** When project's `name` or `logoUrl` changes, all tasks with that project update automatically.

## Adding New Mapping

1. Define embedded reference in schema (include fields to sync)
2. Add entry to `schemaMappings.json`:

```json
{
  "yourResource": {
    "fieldName": {
      "schema": "sourceSchema"
    }
  }
}
```

## Rules

- Only fields defined in the embedded object shape are synced
- Works for both single references and arrays
- Changes sync on source document `updated` event

