mongofiles

package
v0.0.0-...-6df37af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package mongofiles provides an interface to GridFS collections in a MongoDB instance.

Index

Constants

View Source
const (
	List     = "list"
	Search   = "search"
	Put      = "put"
	PutID    = "put_id"
	Get      = "get"
	GetID    = "get_id"
	GetRegex = "get_regex"
	Delete   = "delete"
	DeleteID = "delete_id"
)

List of possible commands for mongofiles.

Variables

View Source
var Usage = `` /* 886-byte string literal not displayed */

Usage string printed as part of --help

Functions

This section is empty.

Types

type InputOptions

type InputOptions struct {
	ReadPreference string `` /* 220-byte string literal not displayed */
}

InputOptions defines the set of options to use in retrieving data from the server.

func (*InputOptions) Name

func (*InputOptions) Name() string

Name returns a human-readable group name for input options.

type MongoFiles

type MongoFiles struct {
	// generic mongo tool options
	ToolOptions *options.ToolOptions

	// mongofiles-specific storage options
	StorageOptions *StorageOptions

	// mongofiles-specific input options
	InputOptions *InputOptions

	// for connecting to the db
	SessionProvider *db.SessionProvider

	// command to run
	Command string

	// filename in GridFS
	FileName string

	// ID to put into GridFS
	Id string

	// List of filenames for use as supporting
	// arguments in put and get commands
	FileNameList []string

	// Regular expression as supporting argument
	// for get_regex
	FileNameRegex string
	// contains filtered or unexported fields
}

MongoFiles is a container for the user-specified options and internal state used for running mongofiles.

func New

func New(opts Options) (*MongoFiles, error)

New constructs a new mongofiles instance from the provided options. Will fail if cannot connect to server or if the provided options are invalid.

func (*MongoFiles) Close

func (mf *MongoFiles) Close()

Close disconnects from the server and cleans up internal mongofiles state.

func (*MongoFiles) Run

func (mf *MongoFiles) Run(displayHost bool) (output string, finalErr error)

Run the mongofiles utility. If displayHost is true, the connected host/port is displayed.

func (*MongoFiles) ValidateCommand

func (mf *MongoFiles) ValidateCommand(args []string) error

ValidateCommand ensures the arguments supplied are valid.

type Options

type Options struct {
	*options.ToolOptions
	*StorageOptions
	*InputOptions
	ParsedArgs []string
}

Options contains all the possible options that can configure mongofiles

func ParseOptions

func ParseOptions(rawArgs []string, versionStr, gitCommit string) (Options, error)

ParseOptions reads command line arguments and converts them into options used to configure a MongoFiles instance

type StorageOptions

type StorageOptions struct {
	// Specified database to use. defaults to 'test' if none is specified
	DB string `short:"d" value-name:"<database-name>" default:"test" default-mask:"-" long:"db" description:"database to use"`

	// 'LocalFileName' is an option that specifies what filename to use for (put|get)
	LocalFileName string `long:"local" value-name:"<filename>" short:"l" description:"local filename for put|get"`

	// 'ContentType' is an option that specifies the Content/MIME type to use for 'put'
	ContentType string `long:"type" value-nane:"<content-type>" short:"t" description:"content/MIME type for put (optional)"`

	// if set, 'Replace' will remove other files with same name after 'put'
	Replace bool `long:"replace" short:"r" description:"remove other files with same name after put"`

	// GridFSPrefix specifies what GridFS prefix to use; defaults to 'fs'
	GridFSPrefix string `long:"prefix" value-name:"<prefix>" default:"fs" default-mask:"-" description:"GridFS prefix to use"`

	// Specifies the write concern for each write operation that mongofiles writes to the target database.
	// By default, mongofiles waits for a majority of members from the replica set to respond before returning.
	// Cannot be used simultaneously with write concern options in a URI.
	WriteConcern string `` /* 192-byte string literal not displayed */

	// RegexOptions specifies the options passed to "$regex" queries that are used for get_regex
	// The default is to use no options, i.e. standard PCRE syntax
	RegexOptions string `long:"regexOptions" default:"" value-name:"<regex-options>" description:"regex options used for get_regex"`
}

StorageOptions defines the set of options to use in storing/retrieving data from server.

func (*StorageOptions) Name

func (*StorageOptions) Name() string

Name returns a human-readable group name for storage options.

Directories

Path Synopsis
Main package for the mongofiles tool.
Main package for the mongofiles tool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL