-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.go
24 lines (20 loc) · 825 Bytes
/
delete.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package mongo
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func (b Client) DeleteOne(database string, collection string, filter bson.M) error {
col, err := b.GetCollection(database, collection, b.config.databaseOptions, b.config.collectionOptions)
if err != nil {
return err
}
_, err = DeleteOne(col, filter, &options.DeleteOptions{})
return err
}
func DeleteOne(collection *mongo.Collection, filter bson.M, deleteOptions *options.DeleteOptions) (*mongo.DeleteResult, error) {
return collection.DeleteOne(Ctx(), filter, deleteOptions)
}
func DeleteMany(collection *mongo.Collection, filter bson.M, deleteOptions *options.DeleteOptions) (*mongo.DeleteResult, error) {
return collection.DeleteMany(Ctx(), filter, deleteOptions)
}