Goofer ORM Examples
Goofer ORM includes several examples to help you understand its features and capabilities. These examples demonstrate various ways to utilize the ORM for different scenarios and database types.
Basic Example
The basic example shows simple CRUD operations with an SQLite database:
- Entity definition and registration
- Connection setup
- Table creation
- Basic CRUD operations (Create, Read, Update, Delete)
- Simple filtering and querying
See the Basic Example for more details.
Database Dialects
Goofer ORM supports multiple database dialects:
- SQLite (covered in the basic example)
- MySQL - Working with MySQL databases
- PostgreSQL - PostgreSQL integration
Advanced Features
Explore these examples to learn about more advanced features:
- Relationships - One-to-one, one-to-many, and many-to-many relationships
- Migrations - Evolving your database schema over time
- Validation - Using validation tags and custom validation
- Hooks - Lifecycle hooks for automated tasks
- Custom Queries - Advanced querying with raw SQL and aggregate functions
- Soft Delete - Implementing soft delete functionality
- Bulk Operations - Efficient bulk database operations
Complete Applications
For more complex examples showing how to put it all together:
- RESTful API - Building a RESTful API with Goofer ORM
- Web Application - Integrating Goofer in a web application
Running Examples
All examples are located in the examples directory of the Goofer ORM repository. To run an example:
cd examples/[example-name]
go run main.goFor instance, to run the basic example:
cd examples/basic
go run main.goThe examples are self-contained and include all the necessary code to demonstrate the featured functionality.
Last updated on