Skip to content

Welcome to Goose 🦆

A Mongoose-inspired MongoDB ODM for Go

Goose is an elegant, type-safe MongoDB Object Document Mapper (ODM) for Go, heavily inspired by the beloved Node.js library Mongoose. Built on top of the official mongo-driver, Goose leverages Go 1.18+ Generics to provide a robust, developer-friendly API.

Why Goose?

Writing MongoDB interactions in Go can sometimes feel verbose, especially when dealing with nested bson maps, manual references, and boilerplate CRUD operations.

Goose bridges the gap by providing:

  • Type Safety First: Generics mean you catch errors at compile time, not runtime.
  • Familiarity: If you've used Mongoose in Node.js, Goose will feel right at home.
  • Less Boilerplate: Automatic schema validation, population, and hooks out of the box.

Key Features

  • 🛡️ Type-safe CRUD: Leverages Go 1.18+ Generics (Model[T]).
  • 🔗 Fluent Query Builder: Chain operations securely with clone-on-write.
  • 🤝 Population: Easily resolve $lookup joins via struct tags.
  • ⚡ Virtual Fields: Define computed properties effortlessly.
  • 🪝 Middleware / Hooks: Interface-based and schema-level lifecycle events.
  • 🛠️ Aggregation Builder: Create complex pipelines with ease.
  • 📦 Plugin System: Extend functionality globally.

Ready to dive in?

Check out the Installation guide and the Quick Start tutorial to get up and running in minutes!