当前位置: 首页>>代码示例>>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;未经允许,请勿转载。