bsoneach v0.2.0 BSONEach

This module allows to apply callback function to each document in a BSON file.

Source file should be opened in :binary mode.

Examples

"sample.bson"
|> File.open!([:read, :binary, :raw])
|> BSONEach.each(&IO.inspect/1)
|> File.close

Summary

Functions

This module allows to apply callback function to each document in a BSON file

Functions

each(io, func)

Specs

each(IO.device, Func) :: IO.iodata | IO.nodata

This module allows to apply callback function to each document in a BSON file.

Source file should be opened in :binary, :raw modes. BSONEach can accept file streams.

It returns:

  • io_device - when file is parsed successfully.
  • {:parse_error, reason} - in case there was an error while parsing BSON document. Possible reasons: :corrupted_document.
  • {:io_error, reason} - in case IO.binstream returned an error.

Examples

"sample.bson"
|> File.open!([:read, :binary, :raw])
|> BSONEach.each(&IO.inspect/1)
|> File.close