SQL GORM for Tinh Tinh is a powerful database toolkit designed to work seamlessly with the Tinh Tinh framework. It provides an elegant and efficient way to interact with SQL databases using GORM, the fantastic ORM library for Golang.
- 🚀 Full GORM integration with Tinh Tinh
- 📦 Easy-to-use database operations
- 🔄 Auto Migration support
- 🎯 Type-safe query building
- 🛠️ Advanced features like:
- Associations handling
- Hooks
- Transactions
- Custom data types
- And more!
To install the package, use:
go get -u github.com/tinh-tinh/sqlorm/v2package main
import (
"github.com/tinh-tinh/sqlorm/v2"
)
// User represents your database modeltypeUserstruct {
IDuint`gorm:"primarykey"`NamestringEmailstring
}
funcmain() {
// Initialize your database connectiondb:=sqlorm.New(&sqlorm.Config{
Driver: "postgres",
Host: "localhost",
Port: 5432,
Database: "mydb",
Username: "user",
Password: "password",
})
// Auto migrate your modelsdb.AutoMigrate(&User{})
// Create a new useruser:=User{
Name: "John Doe",
Email: "john@example.com",
}
db.Create(&user)
}The package supports various database configurations:
typeConfigstruct {
Driverstring// "postgres", "mysql", "sqlite"HoststringPortintDatabasestringUsernamestringPasswordstringSSLModestringTimeZonestring
}- PostgreSQL
- MySQL
- SQLite
- Microsoft SQL Server
For detailed documentation and examples, please visit:
We welcome contributions! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues or need help, you can:
- Open an issue in the GitHub repository
- Check our documentation
- Join our community discussions