package main

import (
	"fmt"
	"time"

	"git.nspix.com/golang/rest/v2"
)

type User struct {
	Id   int
	Name string
}

func (u *User) ModuleName() string {
	return "org"
}

func (u *User) TableName() string {
	return "user"
}

func (u *User) Scenario() []string {
	return nil
}

func main() {
	var (
		crud *rest.CRUD
		err  error
	)
	if crud, err = rest.Dialer(&rest.Config{
		Driver:   "mysql",
		Host:     "192.168.9.199",
		Port:     3306,
		Username: "root",
		Password: "root",
		Database: "rest",
	}); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(crud.Attach(&User{}))
	crud.Routes(nil)
	crud.WithDB(crud.DB().Debug())
	time.Sleep(time.Second * 5)
	crud.DB().Exec("select * from aaxxaa")
}
