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


Golang bson.ObjectId類代碼示例

本文整理匯總了Golang中labix/org/v2/mgo/bson.ObjectId的典型用法代碼示例。如果您正苦於以下問題:Golang ObjectId類的具體用法?Golang ObjectId怎麽用?Golang ObjectId使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ObjectId類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CountFollowingBrandByUserId

func CountFollowingBrandByUserId(userId bson.ObjectId) (num int, err error) {
	if !userId.Valid() {
		err = global.InvalidIdError
		return
	}
	return CountFollowBrand(bson.M{"userid": userId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go

示例2: CountReviewByBrandId

func CountReviewByBrandId(brandId bson.ObjectId) (num int, err error) {
	if !brandId.Valid() {
		err = global.InvalidIdError
		return
	}
	return CountReview(bson.M{"brandid": brandId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:review_curd.go

示例3: GetRead

func (c Blog) GetRead(id bson.ObjectId) revel.Result {
	if id.Hex() != "" {
		article := models.GetArticleByObjectId(c.MongoSession, id)
		return c.Render(article)
	}
	return c.NotFound("Invalid article Id.")
}
開發者ID:jango2015,項目名稱:bloggo,代碼行數:7,代碼來源:blog.go

示例4: CountReviewByProductId

func CountReviewByProductId(productId bson.ObjectId) (num int, err error) {
	if !productId.Valid() {
		err = global.InvalidIdError
		return
	}
	return CountReview(bson.M{"productid": productId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:review_curd.go

示例5: FindSomeByUserId

func FindSomeByUserId(userId bson.ObjectId) (r []*Note, err error) {
	if !userId.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindAll(bson.M{"authorid": userId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:note_curd.go

示例6: FindById

func FindById(id bson.ObjectId) (review *Review, err error) {
	if !id.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindOne(bson.M{"_id": id})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:review_curd.go

示例7: FindByUserId

func FindByUserId(userId bson.ObjectId) (r []*FollowBrand, err error) {
	if !userId.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindAll(bson.M{"userid": userId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go

示例8: CountBrandFollowerByBrandId

func CountBrandFollowerByBrandId(brandId bson.ObjectId) (num int, err error) {
	if !brandId.Valid() {
		err = global.InvalidIdError
		return
	}
	return CountFollowBrand(bson.M{"brandid": brandId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go

示例9: FindByBrandId

func FindByBrandId(brandId bson.ObjectId) (r []*FollowBrand, err error) {
	if !brandId.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindAll(bson.M{"brandid": brandId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go

示例10: FindByUserAndBrandId

func FindByUserAndBrandId(userId, brandId bson.ObjectId) (followBrand *FollowBrand, err error) {
	if !userId.Valid() || !brandId.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindOne(bson.M{"userid": userId, "brandid": brandId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go

示例11: FindSomeByAuthorId

func FindSomeByAuthorId(authorId bson.ObjectId) (r []*Post, err error) {
	if !authorId.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindAll(bson.M{"authorid": authorId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:post_curd.go

示例12: FindById

func FindById(id bson.ObjectId) (product *Product, err error) {
	if !id.Valid() {
		err = global.InvalidIdError
		return
	}
	return FindOne(bson.M{"_id": id})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:product_curd.go

示例13: CanModifyComment

// Only called when doing update or delete.
// At inserting, user.OkayToDoAction is sufficient.
// This needs additional action: you can only update or delete a given comment only if it's yours (under a certain level).
func CanModifyComment(db *mgo.Database, inp map[string][]string, correction_level int, user_id bson.ObjectId, user_level int) error {
	rule := map[string]interface{}{
		"content_id": "must",
		"comment_id": "must",
		"type":       "must",
	}
	dat, err := extract.New(rule).Extract(inp)
	if err != nil {
		return err
	}
	// Even if he has the required level, and he is below correction_level, he can't modify other people's comment, only his owns.
	// So we query here the comment and check who is the owner of it.
	if user_level < correction_level {
		content_id_str := basic.StripId(dat["content_id"].(string))
		comment_id_str := basic.StripId(dat["comment_id"].(string))
		auth, err := findCommentAuthor(db, content_id_str, comment_id_str)
		if err != nil {
			return err
		}
		if auth.Hex() != user_id.Hex() {
			return fmt.Errorf("You are not the rightous owner of the comment.")
		}
	}
	return nil
}
開發者ID:Laller,項目名稱:hypecms,代碼行數:28,代碼來源:comments.go

示例14: UpdateByPk

func (a *AbstractModel) UpdateByPk(id bson.ObjectId, update interface{}) error {
	if !id.Valid() {
		return errors.New("20314")
	}

	return a.Update(M{"_id": id}, update, true)
}
開發者ID:nangong92t,項目名稱:go_src,代碼行數:7,代碼來源:abstract.go

示例15: DeleteByUserAndBrandId

func DeleteByUserAndBrandId(userId, brandId bson.ObjectId) (err error) {
	if !userId.Valid() || !brandId.Valid() {
		err = global.InvalidIdError
		return
	}
	return DeleteFollowBrand(bson.M{"userid": userId, "brandid": brandId})
}
開發者ID:kobeld,項目名稱:duoerl,代碼行數:7,代碼來源:follow_brand_curd.go


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