Created
November 28, 2013 18:52
-
-
Save jaybill/7696642 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* See http://godoc.org/bitbucket.org/jaybill/sawsij/framework/model#DbSetup for how to set up a DbSetup object */ | |
| db := &model.DbSetup{} | |
| .... | |
| post := &Post{Name: "Jimmy", Title: "First Post", Slug: "firstpost"} | |
| t := &model.Table{Db: db} | |
| err := t.Insert(post) | |
| // assuming no error, post.Id will now contain the auto-inserted Id. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Here's how you do it if you want to set your own id */ | |
| post := &Post{Id: 4, Name: "Jimmy", Title: "First Post", Slug: "firstpost"} | |
| t := &model.Table{Db: db} | |
| err := t.InsertWithoutAutoId(post) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment