插入或更新标签.
(labelName string)
| 41 | |
| 42 | //插入或更新标签. |
| 43 | func (m *Label) InsertOrUpdate(labelName string) (err error) { |
| 44 | o := orm.NewOrm() |
| 45 | count, _ := o.QueryTable(NewBook().TableNameWithPrefix()).Filter("label", labelName).Count() |
| 46 | m.BookNumber = int(count) + 1 |
| 47 | m.LabelName = labelName |
| 48 | if count == 0 { |
| 49 | _, err = o.Insert(m) |
| 50 | } else { |
| 51 | _, err = o.Update(m) |
| 52 | } |
| 53 | return |
| 54 | } |
| 55 | |
| 56 | //批量插入或更新标签. |
| 57 | func (m *Label) InsertOrUpdateMulti(labels string) { |
no test coverage detected