本文整理汇总了Golang中github.com/coopernurse/gorp.DbMap.Delete方法的典型用法代码示例。如果您正苦于以下问题:Golang DbMap.Delete方法的具体用法?Golang DbMap.Delete怎么用?Golang DbMap.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coopernurse/gorp.DbMap
的用法示例。
在下文中一共展示了DbMap.Delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Delete
func (network *Network) Delete(db *gorp.DbMap) error {
if len(network.UUID) > 0 {
_, err := db.Delete(network)
return err
}
return nil
}
示例2: ProductsDelete
func ProductsDelete(db *gorp.DbMap, params martini.Params, render render.Render) {
id, _ := strconv.ParseInt(params["id"], 0, 64)
_, err := db.Delete(&models.Product{Id: id})
if err == nil {
render.JSON(204, "No content")
} else {
render.JSON(404, "Not found") // Let's just say that's the reason
}
}
示例3: Delete
func (jail *Jail) Delete(db *gorp.DbMap) error {
if len(jail.UUID) == 0 {
/* No UUID means we haven't even persisted to the DB, yet */
return nil
}
for _, device := range jail.NetworkDevices {
device.Delete(db)
}
for _, option := range jail.Options {
db.Delete(option)
}
for _, mount := range jail.Mounts {
db.Delete(mount)
}
for _, route := range jail.Routes {
db.Delete(route)
}
db.Delete(jail)
return nil
}
示例4: DeleteTask
func DeleteTask(r render.Render, params martini.Params, db *gorp.DbMap) {
id, err := strconv.Atoi(params["id"])
if err != nil {
r.JSON(400, map[string]string{"message": "id must be an integer"})
return
}
count, err := db.Delete(&Task{Id: id})
if err != nil {
log.Printf("Failed deleting task %v: %v", id, err)
r.JSON(500, map[string]string{"messaage": "Failed to delete task"})
return
}
if count != 1 {
r.JSON(404, map[string]string{"message": "Task not found"})
return
}
r.JSON(200, map[string]string{})
}
示例5: main
func main() {
var (
dbMap *gorp.DbMap
user *User
iUser interface{}
)
dbMap = SetupDb()
//START CODE OMIT
dbMap.Insert(&User{Id: 1, FirstName: "John", LastName: "Doe"})
PrintTable(dbMap)
iUser, _ = dbMap.Get(User{}, 1)
user = iUser.(*User)
user.FirstName = "James"
dbMap.Update(user)
PrintTable(dbMap)
dbMap.Delete(user)
PrintTable(dbMap)
//END CODE OMIT
}
示例6: DeletePage
func DeletePage(db *gorp.DbMap, p *Page) error {
_, err := db.Delete(p)
return err
}
示例7: RemoveItem
func (m *Menu) RemoveItem(db *gorp.DbMap, item *MenuItem) error {
_, err := db.Delete(item)
return err
}