EUGENIO SOUZA CARVALHO 4 yıl önce
ebeveyn
işleme
3c539c2103
1 değiştirilmiş dosya ile 10 ekleme ve 7 silme
  1. 10 7
      api/mongo.go

+ 10 - 7
api/mongo.go

@@ -800,17 +800,20 @@ func (t *Mongo) FindMany(f *Filter) (cursor *mongo.Cursor, err *errs.Error) {
 	return
 }
 
-func createDebugEvent(options *Filter, eventType string, fn func(event *DebugEvent)) *DebugEvent {
+func createDebugEvent(options *Filter, eventType string, fn func(event *DebugEvent)) {
 	// debug := options.Context.Values().Get("#debug")
-	debug := options.Context.Values().Get("#debug").(*DebugTaks)
-	event := debug.Event(eventType, "")
-	event.Data = iris.Map{}
-	fn(event)
-	return event
+	if options.Context != nil {
+
+		debug, defined := options.Context.Values().Get("#debug").(*DebugTaks)
+		if defined {
+			event := debug.Event(eventType, "")
+			event.Data = iris.Map{}
+			fn(event)
+		}
+	}
 }
 
 func (models *Mongo) Exists(options *Filter) (exists bool, err *errs.Error) {
-
 	defer func() {
 		createDebugEvent(options, "models.exists", func(event *DebugEvent) {
 			event.Data = iris.Map{"response": exists}