Documentation
¶
Index ¶
- Variables
- func FieldTypeStrings() []string
- func OperationStrings() []string
- type Collection
- type CollectionMetadataObserver
- func (o CollectionMetadataObserver) AssessMetadata(raw json.RawMessage) (model.ProofVerdict, []model.ProofDiagnostic, error)
- func (o CollectionMetadataObserver) Description() string
- func (o CollectionMetadataObserver) MatchesResource(config, operation json.RawMessage, source bool) bool
- func (o CollectionMetadataObserver) Plan() (proofevidence.MetadataPlan, error)
- func (o CollectionMetadataObserver) ReadMetadata(ctx context.Context, transport proofevidence.MetadataIO, credential []byte, ...) (metadataJSON json.RawMessage, rows int64, outcome proofevidence.Outcome)
- type CollectionMetadataSnapshot
- type Config
- type Connector
- type Credentials
- type Field
- type FieldType
- type Operation
- type Schema
- type SchemaIntrospector
Constants ¶
This section is empty.
Variables ¶
var ErrSchemaIntrospection = xerror.Unavailable(xerror.SchemaMetadata)
ErrSchemaIntrospection indicates that schema introspection failed.
Functions ¶
func FieldTypeStrings ¶
func FieldTypeStrings() []string
FieldTypeStrings returns a slice of all String values of the enum
func OperationStrings ¶
func OperationStrings() []string
OperationStrings returns a slice of all String values of the enum
Types ¶
type Collection ¶
type Collection struct {
// Name is the name of the collection.
Name string
// Fields is a list of fields discovered by sampling documents in the collection.
Fields []Field
// DocumentCount is the total number of documents in the collection (optional).
DocumentCount int64
}
Collection represents a single collection in the MongoDB database.
type CollectionMetadataObserver ¶
type CollectionMetadataObserver struct {
Host string `json:"host"`
Port uint16 `json:"port"`
Database string `json:"database"`
Collection string `json:"collection"`
AuthDatabase string `json:"auth_database,omitempty"`
}
CollectionMetadataObserver uses a name-filtered catalog command, never records.
func (CollectionMetadataObserver) AssessMetadata ¶
func (o CollectionMetadataObserver) AssessMetadata(raw json.RawMessage) (model.ProofVerdict, []model.ProofDiagnostic, error)
func (CollectionMetadataObserver) Description ¶
func (o CollectionMetadataObserver) Description() string
func (CollectionMetadataObserver) MatchesResource ¶
func (o CollectionMetadataObserver) MatchesResource(config, operation json.RawMessage, source bool) bool
func (CollectionMetadataObserver) Plan ¶
func (o CollectionMetadataObserver) Plan() (proofevidence.MetadataPlan, error)
func (CollectionMetadataObserver) ReadMetadata ¶
func (o CollectionMetadataObserver) ReadMetadata(ctx context.Context, transport proofevidence.MetadataIO, credential []byte, limits proofevidence.Limits) (metadataJSON json.RawMessage, rows int64, outcome proofevidence.Outcome)
type Config ¶
type Config struct {
Host string `json:"host" validate:"required"`
Port int `json:"port" validate:"required,min=1,max=65535"`
Database string `json:"database" validate:"required"`
AuthDatabase string `json:"auth_database,omitempty" validate:"omitempty"`
ConnectTimeout int `json:"connect_timeout,omitempty"`
AllowPrivateHosts bool `json:"allow_private_hosts,omitempty"`
}
Config holds configuration for MongoDB connections.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector connects to MongoDB databases.
func (*Connector) Execute ¶
func (c *Connector) Execute( ctx context.Context, queryData json.RawMessage, params map[string]types.TypedParam, limits ...types.ExecutionLimits, ) (*result.ExecutionResult, error)
Execute executes a MongoDB operation described by queryData with the provided parameters.
queryData must be a JSON object with at least "collection" and "operation" fields. Supported operations:
- Read: OperationFind, OperationAggregate, OperationCountDocuments
- Write: OperationInsertOne, OperationInsertMany, OperationUpdateOne, OperationDeleteOne, OperationUpdateMany, OperationDeleteMany
params are merged into the filter for read operations and write operations that use filters. Write operations require additional fields (document for insertOne, update for updateOne/updateMany).
func (*Connector) IntrospectSchema ¶
IntrospectSchema retrieves the MongoDB schema by sampling documents from each collection.
type Credentials ¶
type Credentials struct {
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
}
Credentials holds MongoDB authentication values.
type Field ¶
type Field struct {
// Name is the field name (key in the document).
Name string
// Type is the inferred BSON type.
Type FieldType
// Nullable indicates whether the field was missing in some sampled documents.
Nullable bool
}
Field represents a field discovered in sampled documents.
type FieldType ¶
type FieldType int
FieldType represents the inferred type of a MongoDB field from BSON data.
const ( FieldTypeUnknown FieldType = iota // unknown FieldTypeStr // string FieldTypeInt // int FieldTypeDouble // double FieldTypeBoolean // boolean FieldTypeObjectID // objectId FieldTypeDate // date FieldTypeTimestamp // timestamp FieldTypeObject // object FieldTypeArray // array FieldTypeBinary // binary FieldTypeDecimal // decimal FieldTypeRegex // regex FieldTypeNull // null FieldTypeMixed // mixed )
func FieldTypeString ¶
FieldTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func FieldTypeValues ¶
func FieldTypeValues() []FieldType
FieldTypeValues returns all values of the enum
func (FieldType) IsAFieldType ¶
IsAFieldType returns "true" if the value is listed in the enum definition. "false" otherwise
func (FieldType) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for FieldType
func (*FieldType) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for FieldType
type Operation ¶
type Operation int
Operation represents a MongoDB operation type.
const ( OperationUnknown Operation = iota // unknown // Read operations OperationFind // find OperationAggregate // aggregate OperationCountDocuments // count_documents // Write operations OperationInsertOne // insert_one OperationInsertMany // insert_many OperationUpdateOne // update_one OperationDeleteOne // delete_one OperationUpdateMany // update_many OperationDeleteMany // delete_many )
func OperationString ¶
OperationString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func OperationValues ¶
func OperationValues() []Operation
OperationValues returns all values of the enum
func (Operation) IsAOperation ¶
IsAOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (Operation) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Operation
func (*Operation) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for Operation
type Schema ¶
type Schema struct {
// Collections is a list of collections in the data source.
Collections []Collection
}
Schema represents the MongoDB schema of a data source.
type SchemaIntrospector ¶
type SchemaIntrospector interface {
// IntrospectSchema retrieves the MongoDB schema (collections, fields, types).
// Samples documents to infer field types since MongoDB is schemaless.
IntrospectSchema(ctx context.Context) (*Schema, error)
}
SchemaIntrospector retrieves MongoDB schema metadata.