add logic to store event modification and deleted event
This commit is contained in:
@@ -18,6 +18,7 @@ type Event struct {
|
||||
MaxSubscribers int64 `json:"max_subscribers"`
|
||||
Subscriptions []Subscription `json:"subscriptions" bson:"subscriptions,omitempty"`
|
||||
Data map[string]any `json:"data"`
|
||||
Deleted bool `json:"deleted"`
|
||||
}
|
||||
|
||||
type Subscription struct {
|
||||
|
||||
@@ -120,3 +120,13 @@ func (s MongoDBStorage) AddSubscription(eventid string, subscription Subscriptio
|
||||
_, err := collection.UpdateOne(context.TODO(), filter, push)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s MongoDBStorage) UpdateEvent(event Event) error {
|
||||
collection := s.Client.Database(s.DbName).Collection(s.Collections["events"])
|
||||
if _, err := collection.ReplaceOne(context.TODO(), bson.M{"_id": event.ID}, event); err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ type Storage interface {
|
||||
GetEvent(string) (*Event, error)
|
||||
GetEvents(namespaces []string) ([]Event, error)
|
||||
AddSubscription(eventid string, subscription Subscription) error
|
||||
UpdateEvent(Event) error
|
||||
}
|
||||
type StorageImpl struct {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user