本文整理汇总了Golang中github.com/russross/meddler.Save函数的典型用法代码示例。如果您正苦于以下问题:Golang Save函数的具体用法?Golang Save怎么用?Golang Save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SaveMember
// Creates a new Member.
func SaveMember(user, team int64, role string) error {
r := Role{}
if err := meddler.QueryRow(db, &r, roleFindStmt, user, team); err == nil {
r.Role = role
return meddler.Save(db, memberTable, &r)
}
r.UserID = user
r.TeamID = team
r.Role = role
return meddler.Save(db, memberTable, &r)
}
开发者ID:Jyggafey,项目名称:drone,代码行数:13,代码来源:members.go
示例2: SaveSeries
// Saves a Series
func SaveSeries(series *Series) error {
if series.Id == 0 {
series.Created = time.Now().UTC()
}
series.Updated = time.Now().UTC()
return meddler.Save(db, seriesTable, series)
}
开发者ID:rharter,项目名称:mediaman,代码行数:8,代码来源:series.go
示例3: SaveSeason
// Saves a season
func SaveSeason(s *Season) error {
if s.Id == 0 {
s.Created = time.Now().UTC()
}
s.Updated = time.Now().UTC()
return meddler.Save(db, seasonTable, s)
}
开发者ID:rharter,项目名称:mediaman,代码行数:8,代码来源:season.go
示例4: PutCommit
// PutCommit saves a commit in the datastore.
func (db *Commitstore) PutCommit(commit *model.Commit) error {
if commit.Created == 0 {
commit.Created = time.Now().UTC().Unix()
}
commit.Updated = time.Now().UTC().Unix()
return meddler.Save(db, commitTable, commit)
}
开发者ID:zankard,项目名称:drone,代码行数:8,代码来源:commit.go
示例5: Put
// Put inserts an object into the blobstore.
func (b *Blobstore) Put(path string, data []byte) error {
var blob = resource.Blob{}
meddler.QueryRow(b, &blob, queryBlob, path)
blob.Path = path
blob.Data = string(data)
return meddler.Save(b, tableBlob, &blob)
}
开发者ID:drone,项目名称:drone-dart,代码行数:8,代码来源:blobstore.go
示例6: Put
// Put inserts an object into the blobstore.
func (db *Blobstore) Put(path string, data []byte) error {
var blob = Blob{}
meddler.QueryRow(db, &blob, rebind(blobQuery), path)
blob.Path = path
blob.Data = string(data)
return meddler.Save(db, blobTable, &blob)
}
开发者ID:carnivalmobile,项目名称:drone,代码行数:8,代码来源:blob.go
示例7: SaveRepo
// Creates a new Repository.
func SaveRepo(repo *Repo) error {
if repo.ID == 0 {
repo.Created = time.Now().UTC()
}
repo.Updated = time.Now().UTC()
return meddler.Save(db, repoTable, repo)
}
开发者ID:Jyggafey,项目名称:drone,代码行数:8,代码来源:repos.go
示例8: SaveTeam
// Saves a Team.
func SaveTeam(team *Team) error {
if team.ID == 0 {
team.Created = time.Now().UTC()
}
team.Updated = time.Now().UTC()
return meddler.Save(db, teamTable, team)
}
开发者ID:Jyggafey,项目名称:drone,代码行数:8,代码来源:teams.go
示例9: PutRepo
// PutRepo saves a repo in the datastore.
func (db *Repostore) PutRepo(repo *model.Repo) error {
if repo.Created == 0 {
repo.Created = time.Now().UTC().Unix()
}
repo.Updated = time.Now().UTC().Unix()
return meddler.Save(db, repoTable, repo)
}
开发者ID:voxxit,项目名称:drone,代码行数:8,代码来源:repo.go
示例10: SaveCommit
// Creates a new Commit.
func SaveCommit(commit *Commit) error {
if commit.ID == 0 {
commit.Created = time.Now().UTC()
}
commit.Updated = time.Now().UTC()
return meddler.Save(db, commitTable, commit)
}
开发者ID:karolb,项目名称:drone,代码行数:8,代码来源:commits.go
示例11: SaveUser
// Saves the User account.
func SaveUser(user *User) error {
if user.ID == 0 {
user.Created = time.Now().UTC()
}
user.Updated = time.Now().UTC()
return meddler.Save(db, userTable, user)
}
开发者ID:kevincwq,项目名称:drone,代码行数:8,代码来源:users.go
示例12: PutUser
// PutUser saves a user in the datastore.
func (db *Userstore) PutUser(user *model.User) error {
if user.Created == 0 {
user.Created = time.Now().UTC().Unix()
}
user.Updated = time.Now().UTC().Unix()
return meddler.Save(db, userTable, user)
}
开发者ID:carnivalmobile,项目名称:drone,代码行数:8,代码来源:user.go
示例13: SaveMovie
// Saves a Movie.
func SaveMovie(movie *Movie) error {
if movie.ID == 0 {
movie.Created = time.Now().UTC()
}
movie.Updated = time.Now().UTC()
return meddler.Save(db, movieTable, movie)
}
开发者ID:jerrellmardis,项目名称:mediaman,代码行数:8,代码来源:movies.go
示例14: SaveLibrary
// Saves a Library.
func SaveLibrary(library *Library) error {
if library.ID == 0 {
library.Created = time.Now().UTC()
}
library.Updated = time.Now().UTC()
return meddler.Save(db, libraryTable, library)
}
开发者ID:jerrellmardis,项目名称:mediaman,代码行数:8,代码来源:libraries.go
示例15: SetSecret
func (db *datastore) SetSecret(sec *model.Secret) error {
var got = new(model.Secret)
var err = meddler.QueryRow(db, got, rebind(secretNameQuery), sec.RepoID, sec.Name)
if err == nil && got.ID != 0 {
sec.ID = got.ID // update existing id
}
return meddler.Save(db, secretTable, sec)
}
开发者ID:Ablu,项目名称:drone,代码行数:8,代码来源:secret.go
示例16: PostPerm
// PostPerm saves permission in the datastore.
func (db *Permstore) PostPerm(perm *model.Perm) error {
var _perm = new(model.Perm)
meddler.QueryRow(db, _perm, rebind(permQuery), perm.UserID, perm.RepoID)
if _perm.ID != 0 {
perm.ID = _perm.ID
}
return meddler.Save(db, permTable, perm)
}
开发者ID:voxxit,项目名称:drone,代码行数:9,代码来源:perm.go
示例17: Write
func (db *logstore) Write(job *model.Job, r io.Reader) error {
var log = new(model.Log)
var err = meddler.QueryRow(db, log, rebind(logQuery), job.ID)
if err != nil {
log = &model.Log{JobID: job.ID}
}
log.Data, _ = ioutil.ReadAll(r)
return meddler.Save(db, logTable, log)
}
开发者ID:fclairamb,项目名称:drone,代码行数:9,代码来源:logs.go
示例18: SaveSettings
// Saves the system Settings.
func SaveSettings(settings *Settings) error {
//settingsLock.Lock()
//defer settingsLock.Unlock()
// persist changes to settings
err := meddler.Save(db, settingsTable, settings)
if err != nil {
return err
}
// store updated settings in cache
//*settingsCache = *settings
return nil
}
开发者ID:vito,项目名称:drone,代码行数:15,代码来源:settings.go
示例19: TestMigrateAddRemoveColumns
func TestMigrateAddRemoveColumns(t *testing.T) {
defer tearDown()
if err := setUp(); err != nil {
t.Fatalf("Error preparing database: %q", err)
}
Driver = SQLite
mgr := New(db)
if err := mgr.Add(&revision1{}, &revision3{}).Migrate(); err != nil {
t.Errorf("Can not migrate: %q", err)
}
var columns []*TableInfo
if err := meddler.QueryAll(db, &columns, `PRAGMA table_info(samples);`); err != nil {
t.Errorf("Can not access table info: %q", err)
}
if len(columns) < 5 {
t.Errorf("Expect length columns: %d\nGot: %d", 5, len(columns))
}
var row = AddColumnSample{
ID: 33,
Name: "Foo",
Imel: "[email protected]",
Url: "http://example.com",
Num: 42,
}
if err := meddler.Save(db, "samples", &row); err != nil {
t.Errorf("Can not save into database: %q", err)
}
if err := mgr.MigrateTo(1); err != nil {
t.Errorf("Can not migrate: %q", err)
}
var another_columns []*TableInfo
if err := meddler.QueryAll(db, &another_columns, `PRAGMA table_info(samples);`); err != nil {
t.Errorf("Can not access table info: %q", err)
}
if len(another_columns) != 3 {
t.Errorf("Expect length columns = %d, got: %d", 3, len(columns))
}
}
开发者ID:vito,项目名称:drone,代码行数:46,代码来源:sqlite_test.go
示例20: getUpdateUser
// get/create/update this user
func getUpdateUser(tx *sql.Tx, form *LTIRequest, now time.Time) (*User, error) {
user := new(User)
if err := meddler.QueryRow(tx, user, `SELECT * FROM users WHERE lti_id = $1`, form.UserID); err != nil {
if err != sql.ErrNoRows {
log.Printf("db error loading user %s (%s): %v", form.UserID, form.PersonContactEmailPrimary, err)
return nil, err
}
log.Printf("creating new user (%s)", form.PersonContactEmailPrimary)
user.ID = 0
user.CreatedAt = now
user.UpdatedAt = now
}
// any changes?
changed := user.Name != form.PersonNameFull ||
user.Email != form.PersonContactEmailPrimary ||
user.LtiID != form.UserID ||
user.ImageURL != form.UserImage ||
user.CanvasLogin != form.CanvasUserLoginID ||
user.CanvasID != form.CanvasUserID
// make any changes
user.Name = form.PersonNameFull
user.Email = form.PersonContactEmailPrimary
user.LtiID = form.UserID
user.ImageURL = form.UserImage
user.CanvasLogin = form.CanvasUserLoginID
user.CanvasID = form.CanvasUserID
if user.ID > 0 && changed {
// if something changed, note the update time
log.Printf("user %d (%s) updated", user.ID, user.Email)
user.UpdatedAt = now
}
// always save to note the last signed in time
user.LastSignedInAt = now
if err := meddler.Save(tx, "users", user); err != nil {
log.Printf("db error updating user %s (%s): %v", user.LtiID, user.Email, err)
return nil, err
}
return user, nil
}
开发者ID:RidleyLarsen,项目名称:codegrinder,代码行数:44,代码来源:lti.go
注:本文中的github.com/russross/meddler.Save函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论