Beispiel #1
0
func Create(db *mgo.Database, userId string, interview *models.Interview) error {
	interview.ID = bson.NewObjectId()
	interview.Owner = bson.ObjectIdHex(userId)
	interview.Status = models.NotStarted

	err := GetInterviewC(db).Insert(interview)

	if err != nil {
		return err
	}

	return subdb.GetSubC(db).Update(bson.M{
		"vacancy":   interview.Vacancy,
		"candidate": interview.Candidate,
	}, bson.M{
		"$set": bson.M{
			"interview": interview.ID,
		},
	})
}
Beispiel #2
0
func DeleteByQuery(db *mgo.Database, query map[string]interface{}) error {
	log.Debug("db.vacancy - DeleteByQuery", query)
	err, vacIds := GetIdList(db, query)
	if err != nil {
		return err
	}

	log.Debug("db.vacancy - DeleteByQuery, vacIds", vacIds)

	_, err = GetVacancyC(db).RemoveAll(query)
	if err != nil {
		return err
	}

	subdb.GetSubC(db).RemoveAll(bson.M{
		"_id": bson.M{"$in": vacIds},
	})

	interviewdb.GetInterviewC(db).RemoveAll(bson.M{
		"vacancy": bson.M{"$in": vacIds},
	})

	return err
}