Documentation
¶
Index ¶
- type CollectionLinks
- type Discover
- type Fetcher
- type Link
- type Repository
- func (r Repository) ExistsByID(ctx context.Context, db, collection string, id primitive.ObjectID) (bool, error)
- func (r Repository) ListCollections(ctx context.Context, db string) ([]string, error)
- func (r Repository) ListDatabases(ctx context.Context) ([]string, error)
- func (r Repository) SampleCollection(ctx context.Context, db, collection string, size int) ([]primitive.M, error)
- type RepositoryOptionF
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionLinks ¶
CollectionLinks is a map with all Links found in the database
type Discover ¶
type Discover struct { Fetcher Fetcher // contains filtered or unexported fields }
Discover will walk trought Database using its Fetcher and collect some data about the schema
func (Discover) Collection ¶
func (d Discover) Collection(ctx context.Context, db string, collection string) (CollectionLinks, error)
Collection retrieves all path that can be an ObjectId
type Fetcher ¶
type Fetcher interface { ExistsByID(ctx context.Context, db, collection string, id primitive.ObjectID) (bool, error) ListDatabases(ctx context.Context) ([]string, error) ListCollections(ctx context.Context, db string) ([]string, error) SampleCollection(ctx context.Context, db, collection string, size int) ([]primitive.M, error) }
Fetcher describes all methods needed by Discover
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository contains all methods to access to Mongodb
func NewRepository ¶
func NewRepository(opts ...RepositoryOptionF) *Repository
NewRepository creates a new Repository
func (Repository) ExistsByID ¶
func (r Repository) ExistsByID(ctx context.Context, db, collection string, id primitive.ObjectID) (bool, error)
ExistsByID tests the existence of a document by its ID in a specific database collection
func (Repository) ListCollections ¶
ListCollections will return all collection names for a specific db
func (Repository) ListDatabases ¶
func (r Repository) ListDatabases(ctx context.Context) ([]string, error)
ListDatabases will return all database names that client can access
func (Repository) SampleCollection ¶
func (r Repository) SampleCollection(ctx context.Context, db, collection string, size int) ([]primitive.M, error)
SampleCollection returns a random sample of a specific size from a specific db.collection
type RepositoryOptionF ¶
type RepositoryOptionF func(*Repository)
RepositoryOptionF describes a func that will be called from the New func
func RepositoryWithClient ¶
func RepositoryWithClient(c *mongo.Client) RepositoryOptionF
RepositoryWithClient allows caller to set a specific client which will be used to request