Пример #1
0
func Delete(c *gin.Context) {
	db := utils.GetDb(c)
	userId := utils.GetUserId(c)
	id := c.Params.ByName("id")
	err, sub := subdb.Delete(db, userId, id)
	if err != nil {
		log.Debug(err)
		c.Error(err)
		return
	}

	interviewdb.GetInterviewC(db).RemoveId(sub.Interview)

	c.JSON(http.StatusOK, sub)
}
Пример #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
}