本文整理匯總了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}