diff --git a/dri/mongodb/mongodb.go b/dri/mongodb/mongodb.go index 437301f..24c1964 100644 --- a/dri/mongodb/mongodb.go +++ b/dri/mongodb/mongodb.go @@ -65,6 +65,32 @@ func (that *mongoDb) InsertMany(table string, data ...interface{}) Slice { } +func (that *mongoDb) Update(table string, data Map, where Map) int64 { + collection := that.DataBase.Collection(table) + re, err := collection.UpdateMany(that.Ctx, where, data) + + if err != nil { + that.LastErr = err + return 0 + } + + return re.ModifiedCount + +} + +func (that *mongoDb) Delete(table string, where Map) int64 { + collection := that.DataBase.Collection(table) + re, err := collection.DeleteMany(that.Ctx, where) + + if err != nil { + that.LastErr = err + return 0 + } + + return re.DeletedCount + +} + func (that *mongoDb) Get(table string, where Map) Map { results := []Map{} var cursor *mongo.Cursor