npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rakmaster/mongo-aggregation-builder

v0.2.1

Published

A Vue.js GUI component for building MongoDB aggregation pipelines, inspired by MongoDB Compass

Readme

Mongo Aggregation Builder

A Vue.js GUI component for building MongoDB aggregation pipelines, inspired by the interface in MongoDB Compass. This is a web-compatible package that runs entirely in the browser.

Demo

Check out the live demo to see the component in action.

Features

  • Visual Pipeline Builder: Drag-and-drop interface for creating aggregation stages, inspired by MongoDB Compass
  • Complete Stage Support: All 42 MongoDB aggregation pipeline stages including $match, $group, $lookup, $facet, $search, and more
  • Multiple Views: Switch between visual Stages View and raw JSON Text View for maximum flexibility
  • Real-time Output: Generate JSON pipeline and MongoDB query formats instantly as you build
  • Browser Compatible: Runs entirely in the browser without Node.js dependencies
  • Fully Themeable: Customize appearance with CSS variables to match your application's design
  • TypeScript Support: Full TypeScript definitions for all stages and configurations
  • Event-Driven: Listen to pipeline changes and export events for integration

Installation

npm install @rakmaster/mongo-aggregation-builder

Usage

<template>
  <MongoAggregationBuilder
    :theme="customTheme"
    :initial-pipeline="existingPipeline"
    @pipeline-change="onPipelineChange"
    @export-pipeline="onExportPipeline"
  />
</template>

<script setup>
import { MongoAggregationBuilder } from '@rakmaster/mongo-aggregation-builder'
import '@rakmaster/mongo-aggregation-builder/style'

const existingPipeline = [
  { "$match": { "status": "active" } },
  { "$group": { "_id": "$category", "count": { "$sum": 1 } } }
]

const customTheme = {
  'bg-color': '#1a1a1a',
  'text-color': '#ffffff',
  'button-bg': '#4a9eff'
}

const onPipelineChange = (pipeline) => {
  console.log('Pipeline updated:', pipeline)
  // Save to your backend or local storage
}

const onExportPipeline = (pipeline) => {
  console.log('Export requested:', pipeline)
  // Handle export (copy to clipboard, download file, etc.)
}
</script>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | theme | ThemeConfig | {} | CSS variables for theming | | initialPipeline | Pipeline | [] | Initial aggregation pipeline to load |

Events

| Event | Parameters | Description | |-------|------------|-------------| | pipelineChange | pipeline: Pipeline | Emitted when the pipeline changes | | exportPipeline | pipeline: Pipeline | Emitted when export button is clicked |

Supported Aggregation Stages

The component supports all 42 MongoDB aggregation pipeline stages:

Core Stages:

  • $match, $group, $project, $sort, $limit, $skip, $count, $unwind

Field Operations:

  • $addFields, $set, $unset, $replaceRoot, $replaceWith

Array Operations:

  • $unwind

Join Operations:

  • $lookup, $graphLookup, $unionWith

Grouping & Bucketing:

  • $bucket, $bucketAuto, $sortByCount, $facet

Geospatial:

  • $geoNear

Search:

  • $search, $searchMeta

Output & Merge:

  • $out, $merge

Advanced:

  • $sample, $redact, $collStats, $indexStats, $currentOp, $listSessions, $listLocalSessions, $planCacheStats, $changeStream, $changeStreamSplitLargeEvent, $densify, $fill, $setWindowFields, $shardedDataDistribution, $documents

ThemeConfig

interface ThemeConfig {
  [key: string]: string // CSS variable names and values
}

Views

Stages View

Visual editor with cards for each pipeline stage. Add, edit, delete, and reorder stages.

Text View

Direct JSON editing of the entire pipeline array.

Output Formats

JSON Pipeline

[
  { "$match": { "status": "active" } },
  { "$group": { "_id": "$category", "count": { "$sum": 1 } } }
]

MongoDB Query

db.collection.aggregate([
  { "$match": { "status": "active" } },
  { "$group": { "_id": "$category", "count": { "$sum": 1 } } }
])

Theming

Customize the appearance using CSS variables:

:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --button-bg: #007bff;
  --button-hover-bg: #0056b3;
  --border-color: #cccccc;
  --input-bg: #ffffff;
  --error-color: #dc3545;
}

Vuetify Integration

The component automatically adapts to Vuetify themes when used within a Vuetify application. It will use Vuetify's CSS custom properties as fallback values, so the component will match your Vuetify theme out of the box.

Supported Vuetify theme variables:

  • --v-theme-primary - Primary color
  • --v-theme-surface - Background color
  • --v-theme-on-surface - Text color on surfaces
  • --v-theme-outline - Border color
  • --v-theme-surface-variant - Input background
  • --v-theme-error - Error color
  • --v-theme-error-container - Error background
  • --v-theme-font - Font family

Development

npm install
npm run dev    # Watch mode
npm run build  # Build for production

License

MIT