pgorm

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 9 Imported by: 0

README

pgorm

This library combines PostgreSQL and GORM for simplified database interactions.

Quickstart

Make sure you've set these required environment variables:

PGORM_URL="postgres://username:password@localhost:5432/database_name?sslmode=disable"

Here's a simple code to demonstrates how to use it:

package main

import (
    "fmt"

    "github.com/kaptika/pgorm"
)

func main() {
    // Open database connection
    pgorm.Open()

    var result int64

    err := pgorm.DB.Raw("SELECT 1 + 1").Scan(&result).Error
    if err != nil {
        panic(err)
    }

    fmt.Println("result:", result)

    // Close the connection
    pgorm.Close()
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func Close

func Close() error

func Open

func Open()

Types

type Config

type Config struct {
	URL             string `env:"PGORM_URL" validate:"required"`
	MaxIdleConns    int    `env:"PGORM_MAX_IDLE_CONNS, default=10"`
	MaxOpenConns    int    `env:"PGORM_MAX_OPEN_CONNS, default=100"`
	RevealLogValues bool   `env:"PGORM_REVEAL_LOG_VALUES, default=false"`
}

Jump to

Keyboard shortcuts

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