package organization import ( "context" "git.sendico.io/tech/sxchnge/bff/pkg/mutil/mzap" "go.mongodb.org/mongo-driver/v2/bson" "go.uber.org/zap" ) // DeleteCascade deletes an organization and all its related data (projects, tasks, comments, reactions, statuses) func (db *OrganizationDB) DeleteCascade(ctx context.Context, organizationRef bson.ObjectID) error { db.DBImp.Logger.Debug("Starting organization deletion with projects", mzap.OrgRef(organizationRef)) // Delete the organization itself if err := db.Unprotected().Delete(ctx, organizationRef); err != nil { db.DBImp.Logger.Warn("Error deleting organization", zap.Error(err), mzap.OrgRef(organizationRef)) return err } db.DBImp.Logger.Debug("Successfully deleted organization with projects", mzap.OrgRef(organizationRef)) return nil }