pgorm

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 9 Imported by: 0

README

pgorm

This library combines PostgreSQL and GORM for simplified database interactions.

Quickstart

Make sure the environment variables are set (refer to .env.example).

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

package main

import (
    "fmt"

    "github.com/emitra-labs/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