2024-07-20 01:09:42 +00:00
|
|
|
package events
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2024-07-23 14:53:01 +00:00
|
|
|
server "grain/server/types"
|
|
|
|
|
2024-07-20 01:09:42 +00:00
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
|
|
)
|
|
|
|
|
2024-07-23 14:53:01 +00:00
|
|
|
func HandleKind1(ctx context.Context, evt server.Event, collection *mongo.Collection) error {
|
2024-07-20 01:09:42 +00:00
|
|
|
// Insert event into MongoDB
|
|
|
|
_, err := collection.InsertOne(ctx, evt)
|
|
|
|
if err != nil {
|
2024-07-22 17:50:43 +00:00
|
|
|
return fmt.Errorf("Error inserting event into MongoDB: %v", err)
|
2024-07-20 01:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Inserted event kind 1 into MongoDB:", evt.ID)
|
|
|
|
return nil
|
|
|
|
}
|