Remove custom errors

v2
Nikita Tokarchuk 4 years ago
parent 1d3e29fe10
commit 22a1d7033f
  1. 9
      mongox/database/count.go
  2. 2
      mongox/database/deletearray.go
  3. 7
      mongox/database/deleteone.go

@ -1,11 +1,8 @@
package database package database
import ( import (
"fmt"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"github.com/mainnika/mongox-go-driver/v2/mongox"
"github.com/mainnika/mongox-go-driver/v2/mongox/query" "github.com/mainnika/mongox-go-driver/v2/mongox/query"
) )
@ -21,12 +18,6 @@ func (d *Database) Count(target interface{}, filters ...interface{}) (result int
opts.Skip = composed.Skipper() opts.Skip = composed.Skipper()
result, err = collection.CountDocuments(d.Context(), composed.M(), opts) result, err = collection.CountDocuments(d.Context(), composed.M(), opts)
if err == mongox.ErrNoDocuments {
return 0, err
}
if err != nil {
return 0, fmt.Errorf("can't decode desult: %w", err)
}
return return
} }

@ -49,7 +49,7 @@ func (d *Database) DeleteArray(target interface{}) (err error) {
result, err := collection.DeleteMany(d.Context(), primitive.M{"_id": primitive.M{"$in": ids}}, opts) result, err := collection.DeleteMany(d.Context(), primitive.M{"_id": primitive.M{"$in": ids}}, opts)
if err != nil { if err != nil {
return fmt.Errorf("can't create find and delete result: %w", err) return
} }
if result.DeletedCount != int64(targetLen) { if result.DeletedCount != int64(targetLen) {
err = fmt.Errorf("can't verify delete result: removed count mismatch %d != %d", result.DeletedCount, targetLen) err = fmt.Errorf("can't verify delete result: removed count mismatch %d != %d", result.DeletedCount, targetLen)

@ -7,7 +7,6 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
"github.com/mainnika/mongox-go-driver/v2/mongox"
"github.com/mainnika/mongox-go-driver/v2/mongox/base" "github.com/mainnika/mongox-go-driver/v2/mongox/base"
"github.com/mainnika/mongox-go-driver/v2/mongox/query" "github.com/mainnika/mongox-go-driver/v2/mongox/query"
"github.com/mainnika/mongox-go-driver/v2/mongox/utils" "github.com/mainnika/mongox-go-driver/v2/mongox/utils"
@ -39,12 +38,6 @@ func (d *Database) DeleteOne(target interface{}, filters ...interface{}) (err er
} }
err = result.Decode(target) err = result.Decode(target)
if err == mongox.ErrNoDocuments {
return err
}
if err != nil {
return fmt.Errorf("can't decode result: %w", err)
}
return return
} }

Loading…
Cancel
Save