当前位置: 首页>>代码示例>>Golang>>正文


Golang bson.M函数代码示例

本文整理汇总了Golang中gopkg/in/mgo/v2/bson.M函数的典型用法代码示例。如果您正苦于以下问题:Golang M函数的具体用法?Golang M怎么用?Golang M使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了M函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: SetUserDetailInfo

func SetUserDetailInfo(sel, set map[string]interface{}) error {
	c := common.MongoCollection("dudb", "user_detail_info")
	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
开发者ID:sunyuantao,项目名称:windows,代码行数:7,代码来源:user_detail.go

示例2: SetUserInfo

func SetUserInfo(sel, set map[string]interface{}) error {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)
	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
开发者ID:sunyuantao,项目名称:windows,代码行数:7,代码来源:user.go

示例3: SetTeamMember

func SetTeamMember(sel, set map[string]interface{}) error {
	c := common.MongoCollection(TEAM_DB, TEAM_MEMBER_TABLE)

	if err := c.Update(bson.M(sel), bson.M{"$set": bson.M(set)}); err != nil {
		return errors.As(err, sel, set)
	}
	return nil
}
开发者ID:wxaxiaoyao,项目名称:linux,代码行数:8,代码来源:member.go

示例4: setUnsetUpdateAnnotations

// setUnsetUpdateAnnotations returns a bson.D for use
// in an annotationsC txn.Op's Update field, containing $set and
// $unset operators if the corresponding operands
// are non-empty.
func setUnsetUpdateAnnotations(set, unset bson.M) bson.D {
	var update bson.D
	replace := inSubdocReplacer("annotations")
	if len(set) > 0 {
		set = bson.M(copyMap(map[string]interface{}(set), replace))
		update = append(update, bson.DocElem{"$set", set})
	}
	if len(unset) > 0 {
		unset = bson.M(copyMap(map[string]interface{}(unset), replace))
		update = append(update, bson.DocElem{"$unset", unset})
	}
	return update
}
开发者ID:imoapps,项目名称:juju,代码行数:17,代码来源:annotations.go

示例5: InsertSingle

func (repository MongoRepository) InsertSingle(request *messaging.ObjectRequest) RepositoryResponse {
	request.Log("Starting INSERT-SINGLE")
	response := RepositoryResponse{}
	collection, isError, errorMessage := getMongoConnection(request)
	key := getMongoDBRecordID(request, nil)
	if isError == true {
		response.GetErrorResponse(errorMessage)
	} else if key != "" {

		request.Body.Object[request.Body.Parameters.KeyProperty] = key
		request.Body.Object["_id"] = request.Controls.Namespace + "." + request.Controls.Class + "." + key

		err := collection.Insert(bson.M(request.Body.Object))
		if err != nil {
			response.IsSuccess = false
			response.GetErrorResponse("Error inserting one object in mongo" + err.Error())
		} else {
			response.IsSuccess = true
			response.Message = "Successfully inserted one object in Mongo"
			request.Log(response.Message)
		}
	}
	var Data []map[string]interface{}
	Data = make([]map[string]interface{}, 1)
	var actualData map[string]interface{}
	actualData = make(map[string]interface{})
	actualData["ID"] = key
	Data[0] = actualData
	response.Data = Data
	return response
}
开发者ID:sajeetharan,项目名称:v6engine,代码行数:31,代码来源:Mongo.go

示例6: GetOneModel

func (db *MongoDatabaseSession) GetOneModel(mongoQuery M, result interface{}) error {
	collectionName := tools.GetInnerTypeName(result)
	log.Println(collectionName)
	collection := db.Database.C(collectionName)
	err := collection.Find(bson.M(mongoQuery)).One(result)
	return err
}
开发者ID:benji-bou,项目名称:goappuser,代码行数:7,代码来源:dbm.go

示例7: setUnsetUpdateSettings

// setUnsetUpdateSettings returns a bson.D for use
// in a settingsC txn.Op's Update field, containing
// $set and $unset operators if the corresponding
// operands are non-empty.
func setUnsetUpdateSettings(set, unset bson.M) bson.D {
	var update bson.D
	replace := inSubdocReplacer("settings")
	if len(set) > 0 {
		set = bson.M(copyMap(map[string]interface{}(set), replace))
		update = append(update, bson.DocElem{"$set", set})
	}
	if len(unset) > 0 {
		unset = bson.M(copyMap(map[string]interface{}(unset), replace))
		update = append(update, bson.DocElem{"$unset", unset})
	}
	if len(update) > 0 {
		update = append(update, bson.DocElem{"$inc", bson.D{{"version", 1}}})
	}
	return update
}
开发者ID:pmatulis,项目名称:juju,代码行数:20,代码来源:settings.go

示例8: confirm

// confirm adds to filter confirm clause
func confirm(filter model.Fields) bson.M {
	if filter == nil {
		filter = model.Fields{}
	}
	filter["confirm"] = true
	return bson.M(filter)
}
开发者ID:Kaign,项目名称:juno,代码行数:8,代码来源:mgo_db.go

示例9: ReadAppBuildTaskList

func ReadAppBuildTaskList(m map[string]interface{}) ([]AppBuildTask, error) {
	fmt.Println(m)
	fmt.Println(bson.M(m))
	var list []AppBuildTask
	err := taskCollection.Find(m).All(&list)
	return list, err
}
开发者ID:ryanhoo,项目名称:AppManager,代码行数:7,代码来源:appbuildTask.go

示例10: buildUpdateObj

func (bs *BaseStack) buildUpdateObj(m *stack.Machine, s *DialState, now time.Time) bson.M {
	obj := object.MetaBuilder.Build(bs.Provider.newMetadata(m))

	obj["credential"] = m.Credential.Identifier
	obj["provider"] = bs.Provider.Name
	obj["queryString"] = m.QueryString
	obj["status.modifiedAt"] = now
	obj["status.state"] = m.State.String()
	obj["status.reason"] = m.StateReason

	if s.KiteURL != "" {
		obj["registerUrl"] = s.KiteURL

		if u, err := url.Parse(s.KiteURL); err == nil && u.Host != "" {
			if host, _, err := net.SplitHostPort(u.Host); err == nil {
				u.Host = host
			}

			obj["ipAddress"] = u.Host
		}
	}

	bs.Log.Debug("update object for %q: %+v (%# v)", m.Label, obj, s)

	return bson.M(obj)
}
开发者ID:koding,项目名称:koding,代码行数:26,代码来源:apply.go

示例11: GetUser

//mongodb_user
func (d *MongoDb) GetUser(user_prop map[string]interface{}) (user utah.User, err error) {
	c := d.Session.DB(d.dbname).C(d.users_c_name)
	err = c.Find(bson.M(user_prop)).One(&user)
	if err != nil {
		return user, err
	}
	return user, nil
}
开发者ID:gtfour,项目名称:actuator,代码行数:9,代码来源:mongodb_user.go

示例12: GetTeamList

func GetTeamList(sel map[string]interface{}, start, count int) ([]TeamInfo, error) {
	c := common.MongoCollection(TEAM_DB, TEAM_INFO_TABLE)

	team_list := []TeamInfo{}
	err := c.Find(bson.M(sel)).Skip(start).Limit(count).All(&team_list)

	return team_list, errors.As(err, sel)
}
开发者ID:wxaxiaoyao,项目名称:linux,代码行数:8,代码来源:team.go

示例13: GetUserInfo

func GetUserInfo(sel map[string]interface{}) (*UserInfo, error) {
	c := common.MongoCollection(USER_DB, USER_INFO_TABLE)

	user := &UserInfo{}
	if err := c.Find(bson.M(sel)).One(user); err != nil {
		return nil, errors.As(err, sel)
	}
	return user, nil
}
开发者ID:sunyuantao,项目名称:windows,代码行数:9,代码来源:user.go

示例14: GetModels

//GetModels retrieves all the data from mongoDB
//mongoQuery is the query from MongoDB query
//resultInterface is a slice representing the model required, it will be fill with the result of the query
//limit of result if limit < 0 no limit used
//skip corresponding the number elements to skip
//return an err if soimething bad appened
func (db *MongoDatabaseSession) GetModels(mongoQuery M, resultInterface interface{}, limit int, skip int) (interface{}, error) {

	collectionName := tools.GetInnerTypeName(resultInterface)
	collection := db.Database.C(collectionName)
	result := tools.CreatePtrToSliceFromInterface(resultInterface)
	var err error = nil
	switch {
	case limit <= 0 && skip <= 0:
		err = collection.Find(bson.M(mongoQuery)).All(result)
	case limit > 0 && skip <= 0:
		err = collection.Find(bson.M(mongoQuery)).Limit(limit).All(result)
	case limit <= 0 && skip > 0:
		err = collection.Find(bson.M(mongoQuery)).Skip(skip).All(result)
	case limit > 0 && skip > 0:
		err = collection.Find(bson.M(mongoQuery)).Skip(skip).Limit(limit).All(result)
	}
	resultInterface = tools.Dereference(result)
	return resultInterface, err
}
开发者ID:benji-bou,项目名称:goappuser,代码行数:25,代码来源:dbm.go

示例15: Fire

// Fire - the log event
func (h *mongoDB) Fire(entry *logrus.Entry) error {
	entry.Data["Level"] = entry.Level.String()
	entry.Data["Time"] = entry.Time
	entry.Data["Message"] = entry.Message
	mgoErr := h.c.Insert(bson.M(entry.Data))
	if mgoErr != nil {
		return fmt.Errorf("Failed to send log entry to mongodb: %s", mgoErr)
	}
	return nil
}
开发者ID:AcalephStorage,项目名称:minio,代码行数:11,代码来源:logger-mongo-hook.go


注:本文中的gopkg/in/mgo/v2/bson.M函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。