ydb

package module
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

GORM YDB Driver

YDB support for GORM

License Release PkgGoDev tests lint Go Report Card codecov Code lines View examples Telegram WebSite

Quick Start

You can simply test your connection to your database with the following:

package main

import (
	ydb "github.com/PotatoHD404/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)

	// ...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(dsn string, opts ...Option) gorm.Dialector

Types

type Option

type Option = dialect.Option

func With

func With(opts ...ydb.Option) Option

func WithConnMaxIdleTime

func WithConnMaxIdleTime(d time.Duration) Option

func WithMaxIdleConns

func WithMaxIdleConns(n int) Option

func WithMaxOpenConns

func WithMaxOpenConns(n int) Option

func WithTablePathPrefix

func WithTablePathPrefix(tablePathPrefix string) Option

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL