Initial import
This commit is contained in:
22
delete_one.go
Normal file
22
delete_one.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// DeleteOne will delete the first document that matches the filter.
|
||||
func (c *MongoClient) DeleteOne(ctx context.Context, database, name string, filter bson.M) error {
|
||||
|
||||
// 1. Prepare query.
|
||||
collection := c.GetCollection(database, name)
|
||||
|
||||
// 2. Query
|
||||
_, err := collection.DeleteOne(ctx, filter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user