gomongofixtures

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 9 Imported by: 0

README

GOMONGOFIXTURE

It is a simple library to load MongoDB data from files generated by mongoexport utility into your database for testing reasons or whatever reason you'd like.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(ctx context.Context, db *mongo.Database, root string) error

Load loads the given fixture into a database with the given URI using Loader. Each time it creates new Loader and new connection to the database. It uses file name in the path of the fixture as a collection name.

Types

type Fixture

type Fixture struct {
	Path string
}

Fixture describes a fixture: path to a file, database and collection the fixture should be loaded in.

type Loader

type Loader struct {
	DB    *mongo.Database
	Paths map[string]string // Paths to fixture file.
}

Loader loads fixtures into a database.

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) error

Load connects to the database and loads the fixture.

Jump to

Keyboard shortcuts

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