Type-Safe ORM
Built on Go generics with compile-time type checking to prevent runtime errors
Pie brings powerful ORM capabilities to Go with MongoDB, focusing on developer experience and type safety.
Type-Safe ORM
Built on Go generics with compile-time type checking to prevent runtime errors
Smart Query Builder
Intuitive chainable API that makes complex queries readable and maintainable
Struct Query
Convert HTTP request parameters directly to MongoDB queries with struct tags
Multi-Level Caching
Built-in Redis and memory caching with automatic cache invalidation
Lifecycle Hooks
BeforeCreate, AfterUpdate, BeforeDelete hooks for flexible data control
Query Scopes
Reusable query logic with scopes for better code organization
Advanced Aggregation
100+ expression functions and stage builders for complex data processing
Custom Mappers
Flexible field and table name mapping strategies
Error Handling
Comprehensive error types with detailed context information
go get github.com/5xxxx/piepackage main
import ( "context" "log" "github.com/5xxxx/pie")
func main() { // Create engine engine, err := pie.NewEngine( context.Background(), "mydb", pie.WithURI("mongodb://localhost:27017"), ) if err != nil { log.Fatal("Failed to create engine:", err) } defer engine.Disconnect(context.Background())
// Create type-safe session session := pie.Table[User](engine)
// Insert document user := &User{Name: "John Doe", Email: "john@example.com"} result, err := session.Insert(context.Background(), user)
// Query documents var users []User err = session.Where("age", pie.Gte("age", 18)).Find(context.Background(), &users)}Quick Start
Learn how to connect to database, define models and perform basic operations
Core Features
Deep dive into query builder, aggregation, transaction management and more
Advanced Features
Explore advanced features like caching, hooks, soft delete and more
API Reference
View complete API reference documentation and configuration options