2024-07-23 17:22:55 +00:00
|
|
|
package kinds
|
2024-07-20 01:09:42 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|