Documentation
¶
Index ¶
- func BuildTableSummary(ctx context.Context, client *mongo.Client, defaultDatabase, tableName string, ...) (*diff.TableSummaryResult, error)
- func DatabaseSummary(ctx context.Context, client *mongo.Client, summaryName string) (*ansisql.DBDatabase, error)
- func LimitQuery(q string, limit int64) string
- func RunQuery(ctx context.Context, client *mongo.Client, defaultDatabase, queryStr string) (*query.QueryResult, error)
- type Config
- type DB
- func (db *DB) GetDatabaseSummary(ctx context.Context) (*ansisql.DBDatabase, error)
- func (db *DB) GetIngestrURI() (string, error)
- func (db *DB) GetTableSummary(ctx context.Context, tableName string, schemaOnly bool) (*diff.TableSummaryResult, error)
- func (db *DB) IsSchemaless() bool
- func (db *DB) Limit(q string, limit int64) string
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) Select(ctx context.Context, q *query.Query) ([][]interface{}, error)
- func (db *DB) SelectWithSchema(ctx context.Context, q *query.Query) (*query.QueryResult, error)
- type MongoConnection
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
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 ¶
func (*Config) GetIngestrURI ¶
type DB ¶
type DB struct {
Name string
// contains filtered or unexported fields
}
func (*DB) GetDatabaseSummary ¶ added in v0.11.646
GetDatabaseSummary enumerates the databases and collections on the server so `bruin import database` can turn them into assets.
func (*DB) GetIngestrURI ¶
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
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.