Пример #1
0
// UpdateOne updates one host.
func UpdateOne(query interface{}, update interface{}) error {
	return db.Update(
		Collection,
		query,
		update,
	)
}
Пример #2
0
// pull out the task with the specified id from both the in-memory and db
// versions of the task queue
func (self *TaskQueue) DequeueTask(taskId string) error {

	// first, remove from the in-memory queue
	found := false
	for idx, queueItem := range self.Queue {
		if queueItem.Id == taskId {
			found = true
			self.Queue = append(self.Queue[:idx], self.Queue[idx+1:]...)
		}
	}

	// validate that the task is there
	if !found {
		return fmt.Errorf("task id %v was not present in queue for distro"+
			" %v", taskId, self.Distro)
	}

	return db.Update(
		TaskQueuesCollection,
		bson.M{
			TaskQueueDistroKey: self.Distro,
		},
		bson.M{
			"$pull": bson.M{
				TaskQueueQueueKey: bson.M{
					TaskQueueItemIdKey: taskId,
				},
			},
		},
	)
}
Пример #3
0
func UpdateOneNotification(query interface{}, update interface{}) error {
	return db.Update(
		NotifyHistoryCollection,
		query,
		update,
	)
}
Пример #4
0
func (self *PushLog) UpdateStatus(newStatus string) error {
	return db.Update(
		PushlogCollection,
		bson.M{
			PushLogIdKey: self.Id,
		},
		bson.M{
			"$set": bson.M{
				PushLogStatusKey: newStatus,
			},
		},
	)
}
Пример #5
0
// UpdateLastRevision updates the last created revision of a project.
func UpdateLastRevision(projectId, revision string) error {
	return db.Update(
		RepositoriesCollection,
		bson.M{
			RepoProjectKey: projectId,
		},
		bson.M{
			"$set": bson.M{
				RepoLastRevisionKey: revision,
			},
		},
	)
}