1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-16 02:22:15 +00:00

Add a ReadOrCreate method:

m := &User{Name: "Kyle"}
// Returns a boolean indicating whether the object was created,
// the primary key of the object, or an error.
created, id, err := orm.ReadOrCreate(m, "Name")
This commit is contained in:
Kyle McCullough
2014-01-21 23:58:57 -06:00
parent edf7982567
commit 190039b6f8
3 changed files with 53 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ type Fielder interface {
// orm struct
type Ormer interface {
Read(interface{}, ...string) error
ReadOrCreate(interface{}, string, ...string) (bool, int64, error)
Insert(interface{}) (int64, error)
InsertMulti(int, interface{}) (int64, error)
Update(interface{}, ...string) (int64, error)