當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DbMap.Delete方法代碼示例

本文整理匯總了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
}
開發者ID:virtbsd,項目名稱:network,代碼行數:8,代碼來源:network.go

示例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
	}
}
開發者ID:joiggama,項目名稱:martini-example,代碼行數:10,代碼來源:products.go

示例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
}
開發者ID:virtbsd,項目名稱:jail,代碼行數:25,代碼來源:jail.go

示例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{})
}
開發者ID:jmptrader,項目名稱:martini-gorp-bootstrap,代碼行數:18,代碼來源:handlers.go

示例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
}
開發者ID:GoSteelProgrammers,項目名稱:talk-review-orms,代碼行數:24,代碼來源:crud.go

示例6: DeletePage

func DeletePage(db *gorp.DbMap, p *Page) error {
	_, err := db.Delete(p)
	return err
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:4,代碼來源:db.go

示例7: RemoveItem

func (m *Menu) RemoveItem(db *gorp.DbMap, item *MenuItem) error {
	_, err := db.Delete(item)
	return err
}
開發者ID:sisteamnik,項目名稱:guseful,代碼行數:4,代碼來源:db.go


注:本文中的github.com/coopernurse/gorp.DbMap.Delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。