예제 #1
0
// 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)
}
예제 #2
0
파일: db.go 프로젝트: himanshugpt/evergreen
// 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
}
예제 #3
0
파일: task.go 프로젝트: pritten/evergreen
// 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
}
예제 #4
0
func (u *DBUser) Insert() error {
	u.CreatedAt = time.Now()
	return db.Insert(Collection, u)
}
예제 #5
0
파일: db.go 프로젝트: himanshugpt/evergreen
// Insert writes the distro to the database.
func (d *Distro) Insert() error {
	return db.Insert(Collection, d)
}
예제 #6
0
func (ar *AlertRecord) Insert() error {
	return db.Insert(Collection, ar)
}
예제 #7
0
파일: task.go 프로젝트: pritten/evergreen
// 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)
}
예제 #8
0
func (self *NotificationHistory) Insert() error {
	return db.Insert(NotifyHistoryCollection, self)
}
예제 #9
0
파일: task.go 프로젝트: tychoish/evergreen
// Insert writes the b to the db.
func (t *Task) Insert() error {
	return db.Insert(Collection, t)
}
예제 #10
0
func (projectRef *ProjectRef) Insert() error {
	return db.Insert(ProjectRefCollection, projectRef)
}
예제 #11
0
func (self *PushLog) Insert() error {
	return db.Insert(PushlogCollection, self)
}
예제 #12
0
파일: patch.go 프로젝트: amidvidy/evergreen
// Insert inserts the patch into the db, returning any errors that occur
func (p *Patch) Insert() error {
	return db.Insert(Collection, p)
}
예제 #13
0
파일: alert.go 프로젝트: tychoish/evergreen
func EnqueueAlertRequest(a *AlertRequest) error {
	a.QueueStatus = Pending
	return db.Insert(Collection, a)
}
예제 #14
0
파일: host.go 프로젝트: bjori/evergreen
func (self *Host) Insert() error {
	event.LogHostCreated(self.Id)
	return db.Insert(Collection, self)
}
예제 #15
0
파일: version.go 프로젝트: sr527/evergreen
func (self *Version) Insert() error {
	return db.Insert(Collection, self)
}
예제 #16
0
파일: build.go 프로젝트: tychoish/evergreen
// Insert writes the b to the db.
func (b *Build) Insert() error {
	return db.Insert(Collection, b)
}
예제 #17
0
func (self *DBEventLogger) LogEvent(event Event) error {
	return db.Insert(self.collection, event)
}