-
Notifications
You must be signed in to change notification settings - Fork 121
Mongo/BSON: no decoder found for orb.Geometry #122
Copy link
Copy link
Closed
Description
I wanted to add a struct containing a featureCollection to mongoDB. Inserting the document isn't an issue, but as soon as I want to fetch the document it fails with the following message: error decoding key routes.0.legs.features.0.geometry: no decoder found for orb.Geometry.
My inserted document looks like this:

type SimulationInput struct {
Status SimulationStatus `json:"status" default:"RUNNING"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
Ship Ship `json:"ship"`
Routes []Route `json:"routes"`
}
type Route struct {
Name string `json:"name"`
TwoWay bool `json:"twoWay"`
Legs *geojson.FeatureCollection `json:"legs"`
}
func (s *MongoStore) SaveSimulationInput(input *data.SimulationInput) interface{} {
result, err := s.inputCollection.InsertOne(context.Background(), input)
if err != nil {
s.logger.Error(err)
}
return result.InsertedID
}
func (s *MongoStore) GetSimulationInput(id string) (*data.SimulationInput, error) {
objectId, err := primitive.ObjectIDFromHex(id)
if err != nil {
return nil, err
}
filterQuery := map[string]interface{}{
"_id": objectId,
}
var simulationInput *data.SimulationInput
if err := s.inputCollection.FindOne(context.Background(), filterQuery).Decode(&simulationInput); err != nil {
return nil, err
}
return simulationInput, nil
}Is this a bug? Or is there anything I can do differently to encode/decode orb.Geometry?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels