db

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PG_CLIENT = &gorm.DB{}
)

Functions

func GetPgClient

func GetPgClient() *gorm.DB

func Init

func Init()

if used, please change Init() to init()

Types

type HomeThing

type HomeThing struct {
	gorm.Model
	Name   string
	Price  float64
	RoomID uint
}

type PersonRoom

type PersonRoom struct {
	gorm.Model
	Name   string `gorm:"uniqueIndex,not null" json:"name"`
	Owner  string `json:"owner"`
	Size   int    `json:"size"`
	HasNet bool   `gorm:"default:false" json:"net"`
}

type PgClient

type PgClient struct {
	DB *gorm.DB
}

func (*PgClient) Delete

func (p *PgClient) Delete() gin.HandlerFunc

delete use uniqKey name curl -X POST http://127.0.0.1:8080/pg/delete?name=lucy_home

func (*PgClient) Insert

func (p *PgClient) Insert() gin.HandlerFunc

create if not have, insert by c.Query()

func (*PgClient) InsertJson

func (p *PgClient) InsertJson() gin.HandlerFunc

insert by json body

{
    "name": "lucy_home",
    "owner": "lucy",
    "net": true,
    "size": 40
}

func (*PgClient) Read

func (p *PgClient) Read() gin.HandlerFunc

read use uniqKey name

func (*PgClient) Update

func (p *PgClient) Update() gin.HandlerFunc

update with json body

{
    "name": "lucy_home",
    "owner": "lucy",
    "net": false,
    "size": 50
}

Jump to

Keyboard shortcuts

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