gowrap

module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT

README

gowrap

Wrapper around gorm ORM to simplify queries, pagination and struct validation.

Installation

go get github.com/abiiranathan/gowrap

Usage

package main

import (
    "github.com/abiiranathan/gowrap/orm"
)

type Post struct {
	ID       uint      `json:"id" gorm:"primaryKey"`
	Title    string    `json:"title" gorm:"not null; unique" validate:"required,max=255"`
	CreateAt time.Time `json:"created_at" validate:"omitempty"`
}


func main(){
    db := orm.ConnectToSqlite3(orm.MemorySQLiteDB, true)
	err := db.AutoMigrate(&Post{})

	if err != nil {
		t.Fatalf("unable to run gorm automigrate: %v", err)
	}
  
	dborm := orm.New(db)
    p := &Post{Title: "My first post", CreateAt: db.NowFunc()}
	err = dborm.Insert(p)
    ...
}

Directories

Path Synopsis
implentation of a safe concurrent generic map
implentation of a safe concurrent generic map
Simple wrapper around http.Server with graceful shutdown and easy tls setup.
Simple wrapper around http.Server with graceful shutdown and easy tls setup.
websocket handler built on top of guerilla/websocket
websocket handler built on top of guerilla/websocket

Jump to

Keyboard shortcuts

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