本文整理匯總了Golang中periwinkle.Tx.First方法的典型用法代碼示例。如果您正苦於以下問題:Golang Tx.First方法的具體用法?Golang Tx.First怎麽用?Golang Tx.First使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類periwinkle.Tx
的用法示例。
在下文中一共展示了Tx.First方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Save
func (o *Group) Save(db *periwinkle.Tx) {
if o.Subscriptions != nil {
var oldSubscriptions []Subscription
db.Model(o).Related(&oldSubscriptions)
for _, oldsub := range oldSubscriptions {
match := false
for _, newsub := range o.Subscriptions {
if newsub.AddressID == oldsub.AddressID {
match = true
break
}
}
if !match {
var o UserAddress
db.First(&o, "id = ?", oldsub.AddressID)
if o.Medium != "noop" && o.Medium != "admin" {
if err := db.Where("address_id = ? AND group_id = ?", oldsub.AddressID, oldsub.GroupID).Delete(Subscription{}).Error; err != nil {
dbError(err)
}
}
}
}
}
if err := db.Save(o).Error; err != nil {
dbError(err)
}
}
示例2: GetMessageByID
func GetMessageByID(db *periwinkle.Tx, id string) *Message {
var o Message
if result := db.First(&o, "id = ?", id); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
return &o
}
示例3: GetShortURLByID
func GetShortURLByID(db *periwinkle.Tx, id string) *ShortURL {
var o ShortURL
if result := db.First(&o, "id = ?", id); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
return &o
}
示例4: GetTwilioSMSMessageBySID
func GetTwilioSMSMessageBySID(db *periwinkle.Tx, sid string) *TwilioSMSMessage {
var o TwilioSMSMessage
if result := db.First(&o, "message_s_id = ?", sid); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
return &o
}
示例5: GetCaptchaByID
func GetCaptchaByID(db *periwinkle.Tx, id string) *Captcha {
var o Captcha
if result := db.First(&o, "id = ?", id); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
return &o
}
示例6: GetUserByID
func GetUserByID(db *periwinkle.Tx, id string) *User {
id = strings.ToLower(id)
var o User
if result := db.First(&o, "id = ?", id); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
o.populate(db)
return &o
}
示例7: GetGroupByID
func GetGroupByID(db *periwinkle.Tx, id string) *Group {
id = strings.ToLower(id)
var o Group
if result := db.First(&o, "id = ?", id); result.Error != nil {
if result.RecordNotFound() {
return nil
}
dbError(result.Error)
}
db.Model(&o).Related(&o.Subscriptions)
return &o
}