|
@@ -248,8 +248,9 @@ func (t *Mongo) Dispatch(f *Filter) {
|
|
|
|
|
|
func (t *Mongo) InsertOne(f *Filter) (res *mongo.InsertOneResult, err *errs.Error) {
|
|
func (t *Mongo) InsertOne(f *Filter) (res *mongo.InsertOneResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.insert.one")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.insert.one", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
f.Insertion = InsertOne
|
|
f.Insertion = InsertOne
|
|
|
|
|
|
@@ -268,8 +269,9 @@ func (t *Mongo) InsertOne(f *Filter) (res *mongo.InsertOneResult, err *errs.Erro
|
|
|
|
|
|
func (t *Mongo) InsertMany(f *Filter) (res *mongo.InsertManyResult, err *errs.Error) {
|
|
func (t *Mongo) InsertMany(f *Filter) (res *mongo.InsertManyResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.insert.many")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.insert.many", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.Insertion = InsertMany
|
|
f.Insertion = InsertMany
|
|
@@ -295,8 +297,9 @@ func (t *Mongo) InsertMany(f *Filter) (res *mongo.InsertManyResult, err *errs.Er
|
|
//Remove os elementos da colecao, selecionados pela query
|
|
//Remove os elementos da colecao, selecionados pela query
|
|
func (t *Mongo) RemoveOne(f *Filter) (res *mongo.DeleteResult, err *errs.Error) {
|
|
func (t *Mongo) RemoveOne(f *Filter) (res *mongo.DeleteResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.remove.one")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.remove.one", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.CheckQuery = true
|
|
f.CheckQuery = true
|
|
@@ -323,8 +326,9 @@ func (t *Mongo) RemoveMany(f *Filter) (res *mongo.DeleteResult, err *errs.Error)
|
|
var lerr error
|
|
var lerr error
|
|
|
|
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.remove.many")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.remove.many", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.CheckQuery = true
|
|
f.CheckQuery = true
|
|
@@ -349,8 +353,9 @@ func (t *Mongo) UpdateOne(f *Filter) (res *mongo.UpdateResult, err *errs.Error)
|
|
var lerr error
|
|
var lerr error
|
|
|
|
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.update.one")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.update.one", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.Insertion = InsertOne
|
|
f.Insertion = InsertOne
|
|
@@ -380,8 +385,9 @@ func (t *Mongo) UpdateMany(f *Filter) (res *mongo.UpdateResult, err *errs.Error)
|
|
)
|
|
)
|
|
|
|
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.update.many")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.update.many", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.Insertion = InsertMany
|
|
f.Insertion = InsertMany
|
|
@@ -475,8 +481,9 @@ func ParseQuery(ctx iriscontext.Context, filter *Filter, basequery string, data
|
|
|
|
|
|
func (t *Mongo) PatchOne(f *Filter) (res *mongo.UpdateResult, err *errs.Error) {
|
|
func (t *Mongo) PatchOne(f *Filter) (res *mongo.UpdateResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.patch.one")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.patch.one", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
f.Insertion = Patch
|
|
f.Insertion = Patch
|
|
f.CheckQuery = true
|
|
f.CheckQuery = true
|
|
@@ -548,8 +555,9 @@ func (t *Mongo) PatchOne(f *Filter) (res *mongo.UpdateResult, err *errs.Error) {
|
|
|
|
|
|
func (t *Mongo) PatchMany(f *Filter) (res *mongo.UpdateResult, err *errs.Error) {
|
|
func (t *Mongo) PatchMany(f *Filter) (res *mongo.UpdateResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.patch.many")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.patch.many", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.Insertion = Patch
|
|
f.Insertion = Patch
|
|
@@ -639,8 +647,9 @@ func (mongo *Mongo) FindOneRx(options *Filter) *ObservableStruct {
|
|
|
|
|
|
func (t *Mongo) FindOne(f *Filter) (res *mongo.SingleResult, err *errs.Error) {
|
|
func (t *Mongo) FindOne(f *Filter) (res *mongo.SingleResult, err *errs.Error) {
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.find.one")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.find.one", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
f.CheckQuery = (f.QueryType != "aggregate")
|
|
f.CheckQuery = (f.QueryType != "aggregate")
|
|
@@ -692,8 +701,9 @@ func (t *Mongo) FindMany(f *Filter) (cursor *mongo.Cursor, err *errs.Error) {
|
|
|
|
|
|
// f.CheckQuery = true
|
|
// f.CheckQuery = true
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(f, "models.find.many")
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(f, "models.find.many", func(event *DebugEvent) {
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
t.exec(f, func(ctx context.Context, collection *mongo.Collection) {
|
|
t.exec(f, func(ctx context.Context, collection *mongo.Collection) {
|
|
@@ -790,20 +800,22 @@ func (t *Mongo) FindMany(f *Filter) (cursor *mongo.Cursor, err *errs.Error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func createDebugEvent(options *Filter, eventType string) *DebugEvent {
|
|
|
|
|
|
+func createDebugEvent(options *Filter, eventType string, fn func(event *DebugEvent)) *DebugEvent {
|
|
// debug := options.Context.Values().Get("#debug")
|
|
// debug := options.Context.Values().Get("#debug")
|
|
debug := options.Context.Values().Get("#debug").(*DebugTaks)
|
|
debug := options.Context.Values().Get("#debug").(*DebugTaks)
|
|
event := debug.Event(eventType, "")
|
|
event := debug.Event(eventType, "")
|
|
event.Data = iris.Map{}
|
|
event.Data = iris.Map{}
|
|
|
|
+ fn(event)
|
|
return event
|
|
return event
|
|
}
|
|
}
|
|
|
|
|
|
func (models *Mongo) Exists(options *Filter) (exists bool, err *errs.Error) {
|
|
func (models *Mongo) Exists(options *Filter) (exists bool, err *errs.Error) {
|
|
|
|
|
|
defer func() {
|
|
defer func() {
|
|
- event := createDebugEvent(options, "models.exists")
|
|
|
|
- event.Data = iris.Map{"response": exists}
|
|
|
|
- event.Error = err
|
|
|
|
|
|
+ createDebugEvent(options, "models.exists", func(event *DebugEvent) {
|
|
|
|
+ event.Data = iris.Map{"response": exists}
|
|
|
|
+ event.Error = err
|
|
|
|
+ })
|
|
}()
|
|
}()
|
|
|
|
|
|
options.Fields = &bson.M{"_id": 1}
|
|
options.Fields = &bson.M{"_id": 1}
|