GetSubscriber in Mongodb
This commit is contained in:
parent
8a29656b9b
commit
86df552bd1
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue