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


Golang db.Insert函數代碼示例

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


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

示例1: Insert

// Insert inserts the TestLog into the database
func (self *TestLog) Insert() error {
	self.Id = bson.NewObjectId().Hex()
	if err := self.Validate(); err != nil {
		return fmt.Errorf("cannot insert invalid test log: %v", err)
	}
	return db.Insert(TestLogCollection, self)
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:8,代碼來源:test_log.go

示例2: TryInsert

// TryInsert writes the manifest to the database if possible.
// If the document already exists, it returns true and the error
// If it does not it will return false and the error
func (m *Manifest) TryInsert() (bool, error) {
	err := db.Insert(Collection, m)
	if mgo.IsDup(err) {
		return true, nil
	}
	return false, err
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:10,代碼來源:db.go

示例3: Archive

// Inserts the task into the old_tasks collection
func (t *Task) Archive() error {
	var update bson.M
	// only increment restarts if have a current restarts
	// this way restarts will never be set for new tasks but will be
	// maintained for old ones
	if t.Restarts > 0 {
		update = bson.M{"$inc": bson.M{
			TaskExecutionKey: 1,
			TaskRestartsKey:  1,
		}}
	} else {
		update = bson.M{
			"$inc": bson.M{TaskExecutionKey: 1},
		}
	}
	err := UpdateOneTask(
		bson.M{TaskIdKey: t.Id},
		update)
	if err != nil {
		return fmt.Errorf("task.Archive() failed: %v", err)
	}
	archive_task := *t
	archive_task.Id = fmt.Sprintf("%v_%v", t.Id, t.Execution)
	archive_task.OldTaskId = t.Id
	archive_task.Archived = true
	err = db.Insert(OldTasksCollection, &archive_task)
	if err != nil {
		return fmt.Errorf("task.Archive() failed: %v", err)
	}
	return nil
}
開發者ID:pritten,項目名稱:evergreen,代碼行數:32,代碼來源:task.go

示例4: Insert

func (u *DBUser) Insert() error {
	u.CreatedAt = time.Now()
	return db.Insert(Collection, u)
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:4,代碼來源:user.go

示例5: Insert

// Insert writes the distro to the database.
func (d *Distro) Insert() error {
	return db.Insert(Collection, d)
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:4,代碼來源:db.go

示例6: Insert

func (ar *AlertRecord) Insert() error {
	return db.Insert(Collection, ar)
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:3,代碼來源:alert_bookkeeping.go

示例7: Insert

// Inserts the task into the tasks collection, and logs an event that the task
// was created.
func (t *Task) Insert() error {
	event.LogTaskCreated(t.Id)
	return db.Insert(TasksCollection, t)
}
開發者ID:pritten,項目名稱:evergreen,代碼行數:6,代碼來源:task.go

示例8: Insert

func (self *NotificationHistory) Insert() error {
	return db.Insert(NotifyHistoryCollection, self)
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:3,代碼來源:notify_history.go

示例9: Insert

// Insert writes the b to the db.
func (t *Task) Insert() error {
	return db.Insert(Collection, t)
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:4,代碼來源:task.go

示例10: Insert

func (projectRef *ProjectRef) Insert() error {
	return db.Insert(ProjectRefCollection, projectRef)
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:3,代碼來源:project_ref.go

示例11: Insert

func (self *PushLog) Insert() error {
	return db.Insert(PushlogCollection, self)
}
開發者ID:himanshugpt,項目名稱:evergreen,代碼行數:3,代碼來源:push.go

示例12: Insert

// Insert inserts the patch into the db, returning any errors that occur
func (p *Patch) Insert() error {
	return db.Insert(Collection, p)
}
開發者ID:amidvidy,項目名稱:evergreen,代碼行數:4,代碼來源:patch.go

示例13: EnqueueAlertRequest

func EnqueueAlertRequest(a *AlertRequest) error {
	a.QueueStatus = Pending
	return db.Insert(Collection, a)
}
開發者ID:tychoish,項目名稱:evergreen,代碼行數:4,代碼來源:alert.go

示例14: Insert

func (self *Host) Insert() error {
	event.LogHostCreated(self.Id)
	return db.Insert(Collection, self)
}
開發者ID:bjori,項目名稱:evergreen,代碼行數:4,代碼來源:host.go

示例15: Insert

func (self *Version) Insert() error {
	return db.Insert(Collection, self)
}
開發者ID:sr527,項目名稱:evergreen,代碼行數:3,代碼來源:version.go


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