This is a sample application demonstrating how to use GORM with Stoolap as the database backend.
- Connects to Stoolap using the standard database/sql driver
- Uses GORM for object-relational mapping
- Demonstrates CRUD operations with two models: User and Product
- Uses in-memory database for easy testing
To run the application:
cd /path/to/stoolap/works/gormapp
go mod tidy # Ensure all dependencies are installed
go run .- This sample uses the MySQL dialect for GORM as a generic SQL dialect
- It uses an in-memory Stoolap database (
memory://gorm_test) for demonstration - For a persistent database, change the DSN to
db:///path/to/database
Since Stoolap has some SQL syntax differences from traditional databases, this sample application:
- Creates tables manually instead of using GORM's AutoMigrate
- Avoids default values in column definitions
- Handles records one by one instead of batch operations
- Uses simpler SQL commands that are supported by Stoolap
- Adds the VERSION() function to Stoolap to support GORM's version checks
This approach allows GORM to work with Stoolap while respecting its current SQL dialect limitations.