Database related operation files reorganization

This commit is contained in:
Florian Sylvain
2023-01-18 20:55:51 +01:00
parent 0461bb08ef
commit 245ddbc137
5 changed files with 98 additions and 77 deletions
+19
View File
@@ -0,0 +1,19 @@
package database
import (
"context"
"errors"
)
func DeleteDocument(location Location, filter interface{}) (int64, error) {
client := GetNewClient()
collection := client.Database(location.Database).Collection(location.Collection)
defer client.Disconnect(context.TODO())
result, err := collection.DeleteOne(context.TODO(), filter)
if err != nil {
return 0, errors.New("something is wrong with filter to delete the document.")
}
return result.DeletedCount, nil
}