Giter VIP home page Giter VIP logo

Comments (6)

paulmach avatar paulmach commented on June 11, 2024 1

I have PR to add support for BSON. Please have a look #123

from orb.

paulmach avatar paulmach commented on June 11, 2024

Weird that it works for insert but not find.

I would guess the FeatureCollection type needs to implement MarshalBSON and UnmarshalBSON. I'm surprised the driver doesn't fallback to MarshalJSON is those aren't available.

from orb.

jclaessens97 avatar jclaessens97 commented on June 11, 2024

Yeah it's really weird... It does fallback to MarshalJSON. But if I wrap MarshalJSON in a function like follows

func (fc FeatureCollection) MarshalBSON() ([]byte, error) {
	return fc.MarshalJSON()
}

I get runtime error: invalid memory address or nil pointer dereference

And if I implement UnmarshalBSON like follows:

func (fc FeatureCollection) UnmarshalBSON(data []byte) error {
	return fc.UnmarshalJSON(data)
}

I get error decoding key routes.0.legs: invalid character 'î' looking for beginning of value

This is my first bigger project in Go, so I'm not entirely sure how I should go about this, but I can't imagine I'm the first who tries to insert a geoJSON in a mongoDB using Go? 😄 Any chance you can point me in the right direction?

from orb.

 avatar commented on June 11, 2024

Weird that it works for insert but not find.

Find decodes the data to Go values. Decode fails because the codec does not know the type to create for an orb.Geometry.

I would guess the FeatureCollection type needs to implement MarshalBSON and UnmarshalBSON.

Yes.

I'm surprised the driver doesn't fallback to MarshalJSON is those aren't available.

BSON and JSON are different data encodings. MarshalJSON returns JSON, not BSON.

from orb.

jclaessens97 avatar jclaessens97 commented on June 11, 2024

Thanks @paulmach, I'll check it on friday!

from orb.

paulmach avatar paulmach commented on June 11, 2024

merged #123 and published https://github.com/paulmach/orb/releases/tag/v0.9.0 with the change

from orb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.