BSON Ruby gem v4

58 views
Skip to first unread message

Peter Giacomo Lombardo

unread,
Mar 3, 2016, 4:14:30 PM3/3/16
to BSON
I used to use `BSON.read_bson_document` and `BSON::Document.from_bson` to load bson files into an array but am having a very hard time finding an example for version 4 of the bson gem.  

Could anyone point me in the right direction?

I've searched the github project and the mongo ruby tutorial but so far have come up empty.


Thanks
Peter

Durran Jordan

unread,
Mar 4, 2016, 9:30:06 PM3/4/16
to BSON
You still need to use BSON::Document.from_bson, but the parameter to that has now changed in 4.0 to a ByteBuffer instead of a StringIO. So essentially you only need to change 1 line of code:

This line: s = StringIO.new(contents[0])
Becomes this: s = BSON::ByteBuffer.new(contents[0])
Reply all
Reply to author
Forward
0 new messages