astaxie/beego — pull request #477 by kylemcc (2014-01-22 15:20:36+00:00)
Title: Add a ReadOrCreate method:

Sorry for the confusion - you should be able to merge this one.

Stealing this pattern from Django - I think it is common enough to warrant having a helper method as part of the API.

ReadOrCreate will take struct defining some fields, and one or more column names to search on. If the object is found based on the search criteria, it will be returned. Otherwise, the object will be inserted and returned.

```
m := &User{Name: "Kyle", Email: "kylemcc@gmail.com", City: "Chicago"}
// 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")
```

Let me know what you think. If this is acceptable, I'll make a pull request to update the documentation as well.