Documentation ¶
Overview ¶
gogetter is a simple sample data manager, a simple factory_girl (https://github.com/thoughtbot/factory_girl) port with a simple database cleaner interface, and designed to be a testing tool.
Supported Database ¶
1. Mongo (Using labix.org/v2/mgo)
<under construction>
2. MySql (Using github.com/coopernurse/gorp)
3. Postgres (Using github.com/coopernurse/gorp)
Index ¶
- Variables
- func AllInVain(name string, dreams ...Dream) (err error)
- func Apocalypse(names ...string) (err error)
- func AscendGoal(child, parent string, lesson func() Lesson)
- func GetTableName(name string) (table string, err error)
- func SetDefaultGetterDb(db Database)
- func SetDefaultTableId(name string)
- func SetGoal(name string, goal Goal)
- func SetTableName(name, table string)
- type Database
- type Dream
- type GoGetter
- func (gg *GoGetter) AllInVain(name string, dreams ...Dream) (err error)
- func (gg *GoGetter) Apocalypse(names ...string) (err error)
- func (gg *GoGetter) Grow(name string, lessons ...Lesson) (dreams Dream, err error)
- func (gg *GoGetter) Realize(name string, lessons ...Lesson) (dreams Dream, err error)
- type Goal
- type Lesson
Constants ¶
This section is empty.
Variables ¶
var ErrGetterNotExist = errors.New("Getter Not Exist")
Functions ¶
func AscendGoal ¶
By default, GetTableName will use parent's table name.
func GetTableName ¶
func SetDefaultGetterDb ¶
func SetDefaultGetterDb(db Database)
func SetDefaultTableId ¶
func SetDefaultTableId(name string)
Table Id is used when gogetter is trying remove records from table, using a simple sql/mongo statement to remove the data. Default Table Id is "Id", its value must be comparable via reflect.DeepEqual.
func SetGoal ¶
SetGoal will save the Goal globally, then all gogetter values could share the same set of goals.
Note: 1. Leading asterisk (*) in name is saved for gogetter. 2. The return value of goal must be a Struct, map or anything else is not supported.
func SetTableName ¶
func SetTableName(name, table string)
Setting table name is optional, if table name is not specifically setted, gogetter will use the pluralization and lower case form of the name as table name, it will also replace all spaces with underscores.
Types ¶
type GoGetter ¶
type GoGetter struct {
// contains filtered or unexported fields
}
func NewGoGetter ¶
func (*GoGetter) AllInVain ¶
Destroy data created by Grow/Realize (Do not use leading * in name with this function).
Usage:
gogetter.AllInVain("Users") // Will destory all "Users" gogetter.AllInVain("Users", user1, user2) // Only destory user1 and user2 gogetter.AllInVain("users", users) // users is a slice of User
func (*GoGetter) Apocalypse ¶
Apocalypse is designed as a handy method to replace AllInVain in cases like simply wipe out all data created by Grow/Realize.
Usage:
gogetter.Apocalypse("Users") // Will remove all "Users" data gogetter.Apocalypse("Users", "Another Goals") // Will remove all "Users" and "Another Goals" data gogetter.Apocalypse() // Will destroy all data