GetSubscriber in Mongodb

This commit is contained in:
mfrigo 2023-12-06 16:12:29 +01:00
parent 8a29656b9b
commit 86df552bd1
1 changed files with 16 additions and 4 deletions

View File

@ -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
}