From ffa341b13d83743d15e909b756b51fa45b3f29df Mon Sep 17 00:00:00 2001 From: Nicolas Caron Date: Wed, 1 Feb 2023 10:09:43 +0100 Subject: [PATCH] init --- storage/mongodb.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/storage/mongodb.go b/storage/mongodb.go index 49e4bc3..417f4c6 100644 --- a/storage/mongodb.go +++ b/storage/mongodb.go @@ -120,3 +120,13 @@ func (s MongoDBStorage) AddSubscription(eventid string, subscription Subscriptio _, err := collection.UpdateOne(context.TODO(), filter, push) return err } + +func (s MongoDBStorage) RemoveSubscription(subscriptionid string, subscription Subscription) error { + collection := s.Client.Database(s.DbName).Collection(s.Collections["events"]) + + filter := bson.M{"_id": subscriptionid} + push := bson.M{"$pull": bson.M{"subscriptions": subscription}} + + _, err := collection.UpdateOne(context.TODO(), filter, push) + return err +}