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


Golang db.FindOne函數代碼示例

本文整理匯總了Golang中github.com/evergreen-ci/evergreen/db.FindOne函數的典型用法代碼示例。如果您正苦於以下問題:Golang FindOne函數的具體用法?Golang FindOne怎麽用?Golang FindOne使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: FindOneProcessRuntime

func FindOneProcessRuntime(query interface{},
	projection interface{}) (*ProcessRuntime, error) {
	runtime := &ProcessRuntime{}
	err := db.FindOne(
		RuntimesCollection,
		query,
		projection,
		db.NoSort,
		runtime,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return runtime, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:15,代碼來源:process_runtime.go

示例2: FindOneTask

func FindOneTask(query interface{}, projection interface{},
	sort []string) (*Task, error) {
	task := &Task{}
	err := db.FindOne(
		TasksCollection,
		query,
		projection,
		sort,
		task,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return task, err
}
開發者ID:pritten,項目名稱:evergreen,代碼行數:15,代碼來源:task.go

示例3: FindOnePushLog

func FindOnePushLog(query interface{}, projection interface{},
	sort []string) (*PushLog, error) {
	pushLog := &PushLog{}
	err := db.FindOne(
		PushlogCollection,
		query,
		projection,
		sort,
		pushLog,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return pushLog, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:15,代碼來源:push.go

示例4: FindOneNotification

func FindOneNotification(query interface{},
	projection interface{}) (*NotificationHistory, error) {
	notificationHistory := &NotificationHistory{}
	err := db.FindOne(
		NotifyHistoryCollection,
		query,
		projection,
		db.NoSort,
		notificationHistory,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return notificationHistory, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:15,代碼來源:notify_history.go

示例5: FindOneTestLogById

func FindOneTestLogById(id string) (*TestLog, error) {
	tl := &TestLog{}
	err := db.FindOne(
		TestLogCollection,
		bson.M{
			TestLogIdKey: id,
		},
		db.NoProjection,
		db.NoSort,
		tl,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return tl, err
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:16,代碼來源:test_log.go

示例6: FindOneProjectRef

// FindOneProjectRef gets a project ref given the owner name, the repo
// name and the project name
func FindOneProjectRef(identifier string) (*ProjectRef, error) {
	projectRef := &ProjectRef{}
	err := db.FindOne(
		ProjectRefCollection,
		bson.M{
			ProjectRefIdentifierKey: identifier,
		},
		db.NoProjection,
		db.NoSort,
		projectRef,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return projectRef, err
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:18,代碼來源:project_ref.go

示例7: FindRepository

// FindRepository gets the repository object of a project.
func FindRepository(projectId string) (*Repository, error) {
	repository := &Repository{}
	err := db.FindOne(
		RepositoriesCollection,
		bson.M{
			RepoProjectKey: projectId,
		},
		db.NoProjection,
		db.NoSort,
		repository,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return repository, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:17,代碼來源:repository.go

示例8: FindTaskQueueForDistro

func FindTaskQueueForDistro(distroId string) (*TaskQueue, error) {
	taskQueue := &TaskQueue{}
	err := db.FindOne(
		TaskQueuesCollection,
		bson.M{
			TaskQueueDistroKey: distroId,
		},
		db.NoProjection,
		db.NoSort,
		taskQueue,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return taskQueue, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:16,代碼來源:task_queue.go

示例9: FindOneTestLog

// FindOneTestLog returns a TestLog, given the test's name, task id,
// and execution.
func FindOneTestLog(name, task string, execution int) (*TestLog, error) {
	tl := &TestLog{}
	err := db.FindOne(
		TestLogCollection,
		bson.M{
			TestLogNameKey:          name,
			TestLogTaskKey:          task,
			TestLogTaskExecutionKey: execution,
		},
		db.NoProjection,
		db.NoSort,
		tl,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	return tl, err
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:20,代碼來源:test_log.go

示例10: FindOneProjectVars

func FindOneProjectVars(projectId string) (*ProjectVars, error) {
	projectVars := &ProjectVars{}
	err := db.FindOne(
		ProjectVarsCollection,
		bson.M{
			ProjectVarIdKey: projectId,
		},
		db.NoProjection,
		db.NoSort,
		projectVars,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	if err != nil {
		return nil, err
	}
	return projectVars, nil
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:19,代碼來源:project_vars.go

示例11: LastNotificationsEventTime

func LastNotificationsEventTime(projectName string) (time.Time,
	error) {

	nAnswers, err := db.Count(
		NotifyTimesCollection,
		bson.M{
			PntProjectNameKey: projectName,
		},
	)

	if err != nil {
		return EarliestDateToConsider, err
	}
	if nAnswers == 0 {
		return EarliestDateToConsider, nil
	}

	if nAnswers > 1 {
		return EarliestDateToConsider, fmt.Errorf("There are %v notification"+
			" times listed for having seen the NOTIFICATION_REPOSITORY “%v”;"+
			" there should be at most one.", nAnswers, projectName)
	}

	event := &ProjectNotificationTime{}
	err = db.FindOne(
		NotifyTimesCollection,
		bson.M{
			PntProjectNameKey: projectName,
		},
		db.NoProjection,
		db.NoSort,
		event,
	)
	if err != nil {
		return EarliestDateToConsider, err
	}
	if err == mgo.ErrNotFound {
		return EarliestDateToConsider, nil
	}

	return event.LastNotificationEventTime, nil
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:42,代碼來源:notify_times.go

示例12: FindOneOldTask

func FindOneOldTask(query interface{}, projection interface{},
	sort []string) (*Task, error) {
	task := &Task{}
	err := db.FindOne(
		OldTasksCollection,
		query,
		projection,
		sort,
		task,
	)
	if err == mgo.ErrNotFound {
		return nil, nil
	}
	if task != nil {
		task.Id = task.OldTaskId
	}
	if task.Id == "" {
		return nil, fmt.Errorf("old task had nil id")
	}
	return task, err
}
開發者ID:pritten,項目名稱:evergreen,代碼行數:21,代碼來源:task.go


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