diff --git a/storage/mongodb.go b/storage/mongodb.go index e3cbe6d..78c49ca 100644 --- a/storage/mongodb.go +++ b/storage/mongodb.go @@ -154,10 +154,22 @@ func (s MongoDBStorage) UpdateEvent(event Event) error { return nil } -func (psql MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) { - return nil, nil +func (s MongoDBStorage) GetSubscriber(subscriber string) ([]Subscription, error) { + collection := s.Client.Database(s.DbName).Collection(s.Collections["events"]) + + filter := bson.M{"namespace": subscriber} + + subscription := []Subscription{} + if err := collection.FindOne(context.TODO(), filter).Decode(subscription); err != nil { + return nil, err + } + return subscription, nil } -func (psql MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) { - return nil, nil +func (s MongoDBStorage) GetSubscriptionByUser(subscriber string) ([]Subscription, error) { + events, err := s.GetSubscriber(subscriber) + if err != nil { + panic(err) + } + return events, nil }