mongo

package
v0.11.689 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTableSummary added in v0.11.646

func BuildTableSummary(ctx context.Context, client *mongo.Client, defaultDatabase, tableName string, schemaOnly bool, sampleSize int64) (*diff.TableSummaryResult, error)

BuildTableSummary produces a diff.TableSummaryResult for a MongoDB collection. MongoDB has no static schema, so the field set, types and nullability are inferred by scanning the documents. When sampleSize > 0 at most that many documents are sampled (via $sample) instead of scanning the whole collection, which makes the resulting statistics approximate.

It is shared by the mongo and mongo_atlas connection types.

func DatabaseSummary added in v0.11.646

func DatabaseSummary(ctx context.Context, client *mongo.Client, summaryName string) (*ansisql.DBDatabase, error)

DatabaseSummary enumerates the databases and collections reachable through the given client and returns them as an ansisql.DBDatabase tree: each MongoDB database maps to a schema and each collection to a table. MongoDB is schemaless, so tables are returned without columns. Row counts are populated best-effort. It is shared by the mongo and mongo_atlas connection types.

func LimitQuery added in v0.11.644

func LimitQuery(q string, limit int64) string

LimitQuery lets `bruin query --limit N` work for MongoDB by injecting the limit into the query envelope. If the query can't be parsed it is returned as-is. Shared by the mongo and mongo_atlas connection types.

func RunQuery added in v0.11.644

func RunQuery(ctx context.Context, client *mongo.Client, defaultDatabase, queryStr string) (*query.QueryResult, error)

RunQuery executes a MongoDB query envelope against the given client and returns a tabular result. defaultDatabase is used when the envelope omits a "database". It is shared by the mongo and mongo_atlas connection types.

Types

type Config

type Config struct {
	Username string
	Password string
	Host     string
	Port     int
	Database string
}

func (*Config) GetIngestrURI

func (c *Config) GetIngestrURI() string

type DB

type DB struct {
	Name string
	// contains filtered or unexported fields
}

func NewDB

func NewDB(c *Config) (*DB, error)

func (*DB) GetDatabaseSummary added in v0.11.646

func (db *DB) GetDatabaseSummary(ctx context.Context) (*ansisql.DBDatabase, error)

GetDatabaseSummary enumerates the databases and collections on the server so `bruin import database` can turn them into assets.

func (*DB) GetIngestrURI

func (db *DB) GetIngestrURI() (string, error)

func (*DB) GetTableSummary added in v0.11.646

func (db *DB) GetTableSummary(ctx context.Context, tableName string, schemaOnly bool) (*diff.TableSummaryResult, error)

GetTableSummary implements diff.TableSummarizer for MongoDB collections. The table identifier is a collection name, optionally qualified as "database.collection".

func (*DB) IsSchemaless added in v0.11.646

func (db *DB) IsSchemaless() bool

IsSchemaless reports that MongoDB has no fixed, catalog-defined schema; the schema is inferred from documents. It implements diff.SchemalessSummarizer so data-diff skips ALTER TABLE statement generation for MongoDB sources.

func (*DB) Limit added in v0.11.644

func (db *DB) Limit(q string, limit int64) string

func (*DB) Ping added in v0.11.644

func (db *DB) Ping(ctx context.Context) error

func (*DB) Select added in v0.11.644

func (db *DB) Select(ctx context.Context, q *query.Query) ([][]interface{}, error)

func (*DB) SelectWithSchema added in v0.11.644

func (db *DB) SelectWithSchema(ctx context.Context, q *query.Query) (*query.QueryResult, error)

type MongoConnection

type MongoConnection interface {
	GetIngestrURI() (string, error)
}

Jump to

Keyboard shortcuts

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