YDB support for GORM
You can simply test your connection to your database with the following:
package main
import (
ydb "github.com/ydb-platform/gorm-driver"
"gorm.io/gorm"
)
type User struct {
Name string `gorm:"primarykey"`
Age int
}
func main() {
db, err := gorm.Open(ydb.Open("grpc://localhost:2136/local"))
if err != nil {
panic("failed to connect database")
}
// Auto Migrate
db.AutoMigrate(&User{})
// Insert
db.Create(&User{Name: "Angeliz", Age: 18})
// Select
db.Find(&User{}, "name = ?", "Angeliz")
// Batch Insert
user1 := User{Name: "Charles", Age: 12}
user2 := User{Name: "Feynman", Age: 13}
user3 := User{Name: "Michael", Age: 14}
users := []User{user1, user2, user3}
db.Create(&users)
// ...
}