Documentation ¶
Overview ¶
Package bsondump converts BSON files into human-readable formats such as JSON.
Index ¶
Constants ¶
const ( DebugOutputType = "debug" JSONOutputType = "json" )
Types out output supported by the --type option
Variables ¶
var Usage = `<options> <file>
View and debug .bson files.
See http://docs.mongodb.com/database-tools/bsondump/ for more information.`
Functions ¶
This section is empty.
Types ¶
type BSONDump ¶
type BSONDump struct { // generic mongo tool options ToolOptions *options.ToolOptions // OutputOptions defines options used to control how BSON data is displayed OutputOptions *OutputOptions // File handle for the output data. OutputWriter io.WriteCloser InputSource *db.BSONSource }
BSONDump is a container for the user-specified options and internal state used for running bsondump.
func New ¶
New constructs a new instance of BSONDump configured by the provided options. A successfully created instance must be closed with Close().
func (*BSONDump) Close ¶
Close cleans up the internal state of the given BSONDump instance. The instance should not be used again after Close is called.
func (*BSONDump) Debug ¶
Debug iterates through the BSON file and for each document it finds, recursively descends into objects and arrays and prints a human readable BSON representation containing the type and size of each field. It returns the number of documents processed and a non-nil error if one is encountered before the end of the file is reached.
func (*BSONDump) JSON ¶
JSON iterates through the BSON file and for each document it finds, recursively descends into objects and arrays and prints the human readable JSON representation. It returns the number of documents processed and a non-nil error if one is encountered before the end of the file is reached.
type Options ¶
type Options struct { *options.ToolOptions *OutputOptions }
Options contains all the possible options used to configure bsondump.
type OutputOptions ¶
type OutputOptions struct { // Format to display the BSON data file Type string `long:"type" value-name:"<type>" default:"json" default-mask:"-" description:"type of output: debug, json"` // Validate each BSON document before displaying ObjCheck bool `long:"objcheck" description:"validate BSON during processing"` // Display JSON data with indents Pretty bool `long:"pretty" description:"output JSON formatted to be human-readable"` // Path to input BSON file BSONFileName string `long:"bsonFile" description:"path to BSON file to dump to JSON; default is stdin"` // Path to output file OutFileName string `long:"outFile" description:"path to output file to dump BSON to; default is stdout"` }
func (*OutputOptions) GetBSONReader ¶
func (oo *OutputOptions) GetBSONReader() (io.ReadCloser, error)
GetBSONReader opens and returns an io.ReadCloser for the BSONFileName in OutputOptions or nil if none is set. The caller is responsible for closing it.
func (*OutputOptions) GetWriter ¶
func (oo *OutputOptions) GetWriter() (io.WriteCloser, error)
GetWriter opens and returns an io.WriteCloser for the OutFileName in OutputOptions or nil if none is set. The caller is responsible for closing it.
func (*OutputOptions) Name ¶
func (*OutputOptions) Name() string
type ReadNopCloser ¶
func (ReadNopCloser) Close ¶
func (ReadNopCloser) Close() error
type WriteNopCloser ¶
func (WriteNopCloser) Close ¶
func (WriteNopCloser) Close() error