Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. MongoDB
  3. Bongo

Bongo

MITGo

A Go ODM for MongoDB that adds object-document mapping, hooks, validation, and cascade support to mgo.

GitHubGitHub
490 stars39 forks0 contributors

What is Bongo?

Bongo is an Object-Document Mapper (ODM) for MongoDB, built as a wrapper around the mgo driver for Go. It provides structured document handling with Go structs, lifecycle hooks, validation, and cascade operations to simplify MongoDB interactions while maintaining access to low-level operations.

Target Audience

Go developers building applications with MongoDB who need a higher-level abstraction for data modeling, validation, and relationship management without losing direct database access.

Value Proposition

Developers choose Bongo for its robust feature set—including hooks, validation, cascade saves/deletes, and change tracking—that fills the gap for a full-featured ODM in Go, offering convention-based simplicity alongside the flexibility to drop down to raw mgo queries when needed.

Overview

Go ODM for MongoDB

Use Cases

Best For

  • Go applications requiring structured data modeling with MongoDB using Go structs and lifecycle hooks.
  • Implementing complex validation logic with structured error handling for MongoDB documents in Go.
  • Managing related documents with cascade save and delete operations to maintain data integrity.
  • Tracking field-level changes in documents for auditing or conditional logic using the built-in diff tracker.
  • Building Go backends that need paginated query results with easy access to underlying MongoDB queries.
  • Projects that want an ODM with pre-save and post-save hooks for custom business logic without sacrificing low-level control.

Not Ideal For

  • Projects requiring absolute API stability for production use, as Bongo's Cascade feature is explicitly marked unstable and subject to breaking changes.
  • Teams using the official MongoDB Go driver or newer alternatives, since Bongo is tightly coupled with the mgo driver, which may lack support for latest MongoDB features.
  • Applications where performance overhead must be minimized, as the ODM abstraction adds layers like change tracking and hooks that can impact speed compared to raw queries.
  • Scenarios needing out-of-the-box transaction support, as Bongo focuses on document-level operations without built-in handling for MongoDB multi-document transactions.

Pros & Cons

Pros

Comprehensive Lifecycle Hooks

Bongo provides BeforeSave, AfterSave, BeforeDelete, AfterDelete, AfterFind, and Validate hooks, allowing custom logic injection at key document lifecycle stages, as detailed in the hooks section of the README.

Structured Validation System

It includes an integrated validation system that returns structured ValidationError objects, making error handling and display straightforward, as shown in the saving models example with type assertion.

Built-in Change Tracking

Offers diff tracking via the Trackable interface to monitor field modifications, useful for auditing or conditional updates, with practical examples in the change tracking section.

Direct Mgo Access

Maintains full access to the underlying mgo driver, enabling developers to drop down to raw MongoDB queries when needed, as highlighted in the philosophy and usage with connection.Session.

Configurable Cascade Operations

Supports cascade save and delete for data integrity across related documents, though unstable, with detailed CascadeConfig setup examples in the README.

Cons

Unstable Cascade Feature

The cascade functionality is labeled unstable in the README and may require refactoring, posing risks for production environments where data consistency is critical.

Dependent on Legacy Mgo

Bongo is built on the mgo driver, which is older and might not integrate well with modern Go modules or support the latest MongoDB advancements, limiting future-proofing.

Complex Cascade Configuration

Setting up cascade operations involves verbose CascadeConfig structs and manual diff tracking, increasing development complexity and potential for errors, as seen in the cascade example.

Sparse Advanced Features

Lacks mention of support for newer MongoDB features like transactions or aggregation pipelines in its ODM layer, requiring fallback to raw mgo which may be cumbersome.

Frequently Asked Questions

Quick Stats

Stars490
Forks39
Contributors0
Open Issues12
Last commit5 years ago
CreatedSince 2014

Tags

#database-driver#hooks#orm#validation#data-modeling#mongodb#go#odm

Built With

G
Go

Included in

MongoDB2.6k
Auto-fetched 19 hours ago

Related Projects

mongo-go-drivermongo-go-driver

The Official Golang driver for MongoDB

Stars8,538
Forks937
Last commit1 day ago
mgomgo

The MongoDB driver for Go

Stars1,963
Forks222
Last commit4 years ago
bsonicbsonic

Parse Lucene-style query syntax into BSON filters for MongoDB — fast, simple, and developer-friendly.

Stars3
Forks0
Last commit5 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub