Documentation ¶
Index ¶
- func ConvertIdsToOids(documents []primitive.M) ([]string, error)
- func GetIDFromDocument(document map[string]interface{}) (primitive.ObjectID, error)
- func GetIDFromJSON(jsonString string) (primitive.ObjectID, error)
- func IndientJSON(jsonString string) (bytes.Buffer, error)
- func ParseStringQuery(query string) (map[string]interface{}, error)
- func StringifyDocument(document map[string]interface{}) (string, error)
- type Client
- type CollectionState
- type DBsWithCollections
- type Dao
- func (d *Dao) AddCollection(ctx context.Context, db string, collection string) error
- func (d *Dao) DeleteCollection(ctx context.Context, db string, collection string) error
- func (d *Dao) DeleteDocument(ctx context.Context, db string, collection string, id primitive.ObjectID) error
- func (d *Dao) ForceClose(ctx context.Context) error
- func (d *Dao) GetDocument(ctx context.Context, db string, collection string, id primitive.ObjectID) (primitive.M, error)
- func (d *Dao) GetLiveSessions(ctx context.Context) (int64, error)
- func (d *Dao) GetServerStatus(ctx context.Context) (*ServerStatus, error)
- func (d *Dao) InsetDocument(ctx context.Context, db string, collection string, document primitive.M) (interface{}, error)
- func (d *Dao) ListDbsWithCollections(ctx context.Context, nameRegex string) ([]DBsWithCollections, error)
- func (d *Dao) ListDocuments(ctx context.Context, db string, collection string, filter primitive.M, ...) ([]primitive.M, int64, error)
- func (d *Dao) UpdateDocument(ctx context.Context, db string, collection string, id primitive.ObjectID, ...) error
- type Filter
- type MongoAutocomplete
- type MongoKeyword
- type ServerStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertIdsToOids ¶
ConvertIdsToOids converts a slice of documents to a slice of strings with the _id field converted to an $oid
func GetIDFromDocument ¶
GetIDFromDocument returns the _id field of a document as a primitive.ObjectID
func GetIDFromJSON ¶
GetIDFromJSON returns the _id field of a JSON string as a primitive.ObjectID.
func IndientJSON ¶
IndientJSON indents a JSON string and returns a a buffer
func ParseStringQuery ¶
ParseStringQuery transforms a query string with ObjectId into a filter map compatible with MongoDB's BSON. If keys are not quoted, this function will quote them.
func StringifyDocument ¶
StringifyDocument converts a map to a JSON string
Types ¶
type Client ¶
type Client struct { Client *mongo.Client Config *config.MongoConfig }
func NewClient ¶
func NewClient(config *config.MongoConfig) *Client
type CollectionState ¶
type DBsWithCollections ¶
type Dao ¶
type Dao struct { Config *config.MongoConfig // contains filtered or unexported fields }
func (*Dao) AddCollection ¶
func (*Dao) DeleteCollection ¶
func (*Dao) DeleteDocument ¶
func (*Dao) GetDocument ¶
func (*Dao) GetServerStatus ¶
func (d *Dao) GetServerStatus(ctx context.Context) (*ServerStatus, error)
func (*Dao) InsetDocument ¶
func (*Dao) ListDbsWithCollections ¶
func (*Dao) ListDocuments ¶
type MongoAutocomplete ¶
type MongoAutocomplete struct {
Operators []MongoKeyword
}
func NewMongoAutocomplete ¶
func NewMongoAutocomplete() *MongoAutocomplete
func (*MongoAutocomplete) GetOperatorByDisplay ¶
func (m *MongoAutocomplete) GetOperatorByDisplay(display string) *MongoKeyword
type MongoKeyword ¶
MongoKeyword represents single mongo keyword Display is displayed in autocomplete InsertText is inserted into input, use <$i> marker to mark position for cursor, if empty then cursor moves to the end of the text Description is displayed in autocomplete description
type ServerStatus ¶
type ServerStatus struct { Ok int32 `bson:"ok"` Version string `bson:"version"` Uptime int32 `bson:"uptime"` CurrentConns int32 `bson:"connections.current"` AvailableConns int32 `bson:"connections.available"` OpCounters struct { Insert int32 `bson:"insert"` Query int32 `bson:"query"` Update int32 `bson:"update"` Delete int32 `bson:"delete"` } `bson:"opcounters"` Mem struct { Resident int32 `bson:"resident"` Virtual int32 `bson:"virtual"` } `bson:"mem"` Repl struct { ReadOnly bool `bson:"readOnly"` IsMaster bool `bson:"ismaster"` } `bson:"repl"` }