Skip to content

betacraft/dpgorm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Defer Panic gorm package

wercker status

GoDoc

Defer Panic gorm add-on pkg

Many deferpanic users use gorm. This is the first attempt to start adding support. Much is left to do and this will probably change dramatically in the near future.

package main

import (
	"github.com/deferpanic/deferclient/deferstats"
	"github.com/deferpanic/dpgorm"
	"github.com/jinzhu/gorm"
	_ "github.com/lib/pq"
	"log"
	"time"
)

type User struct {
	gorm.Model
	Name string
}

func main() {

	dps := deferstats.NewClient("v00L0K6CdKjE4QwX5DL1iiODxovAHUfo")

	_db, err := gorm.Open("postgres", "dbname=gorm sslmode=disable")
	if err != nil {
		log.Println(err)
	}

	db := dpgorm.NewDB(&_db)

	// set our threshold to log everything
	db.SetThreshold(-1)

	go dps.CaptureStats()

	db.AutoMigrate(&User{})

	user := User{Name: "Jinzhu"}
	blah := db.Create(&user)
	log.Println(blah)
	log.Println(db.First(&user))

	var count int
	db.Model(User{}).Where("name = ?", "Jinzhu").Count(&count)
	log.Println(count)

	time.Sleep(120 * time.Second)
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages