Documentation ¶
Index ¶
- func GetIDFromJSON(jsonString string) (interface{}, error)
- func IndentJson(jsonString string) (bytes.Buffer, error)
- func ParseBsonDocument(document map[string]interface{}) (string, error)
- func ParseBsonDocuments(documents []primitive.M) ([]string, error)
- func ParseJsonToBson(jsonDoc string) (primitive.M, error)
- func ParseStringQuery(query string) (map[string]interface{}, error)
- func StringifyId(id interface{}) string
- type Client
- type CollectionState
- func (c *CollectionState) AppendDoc(doc primitive.M)
- func (c *CollectionState) DeleteDoc(id interface{})
- func (c *CollectionState) GetAllDocs() []primitive.M
- func (c *CollectionState) GetDocById(id interface{}) primitive.M
- func (c *CollectionState) GetJsonDocById(id interface{}) (string, error)
- func (c *CollectionState) PopulateDocs(docs []primitive.M)
- func (c *CollectionState) SetFilter(filter string)
- func (c *CollectionState) SetSort(sort string)
- func (c *CollectionState) UpdateRawDoc(doc string) error
- type DBsWithCollections
- type Dao
- func (d *Dao) AddCollection(ctx context.Context, db string, coll string) error
- func (d *Dao) CreateIndex(ctx context.Context, db, coll string, indexDef mongo.IndexModel) error
- func (d *Dao) DeleteCollection(ctx context.Context, db string, coll string) error
- func (d *Dao) DeleteDocument(ctx context.Context, db string, coll string, id interface{}) error
- func (d *Dao) DropIndex(ctx context.Context, db, coll, indexName string) error
- func (d *Dao) ForceClose(ctx context.Context) error
- func (d *Dao) GetDocument(ctx context.Context, db string, coll string, id primitive.ObjectID) (primitive.M, error)
- func (d *Dao) GetIndexes(ctx context.Context, db string, coll string) ([]IndexInfo, 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, coll string, document primitive.M) (interface{}, error)
- func (d *Dao) ListDbsWithCollections(ctx context.Context, nameRegex string) ([]DBsWithCollections, error)
- func (d *Dao) ListDocuments(ctx context.Context, state *CollectionState, filter primitive.M, ...) ([]primitive.M, int64, error)
- func (d *Dao) Ping(ctx context.Context) error
- func (d *Dao) RenameCollection(ctx context.Context, db string, oldColl string, newColl string) error
- func (d *Dao) UpdateDocument(ctx context.Context, db string, coll string, id interface{}, ...) error
- type IndexInfo
- type MongoAutocomplete
- type MongoKeyword
- type ServerStatus
- type StateMap
- func (sm *StateMap) AddHiddenColumn(db, coll, column string)
- func (sm *StateMap) Get(key string) (*CollectionState, bool)
- func (sm *StateMap) GetHiddenColumns(db, coll string) []string
- func (sm *StateMap) Key(db, coll string) string
- func (sm *StateMap) ResetHiddenColumns(db, coll string)
- func (sm *StateMap) Set(key string, state *CollectionState)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIDFromJSON ¶
GetIDFromJSON returns the _id field of a JSON string as a primitive.ObjectID.
func IndentJson ¶
IndentJson indents a JSON string and returns a a buffer
func ParseBsonDocument ¶
ParseBsonDocument converts a map to a JSON string
func ParseBsonDocuments ¶
ParseBsonDocuments converts a slice of documents to a slice of strings with mongo compatible JSON
func ParseJsonToBson ¶
ParseJsonToBson converts a JSON string to a primitive.M document
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 StringifyId ¶
func StringifyId(id interface{}) string
StringifyId converts the _id field of a document to a string
Types ¶
type Client ¶
type Client struct { Client *mongo.Client Config *config.MongoConfig }
func NewClient ¶
func NewClient(config *config.MongoConfig) *Client
type CollectionState ¶
type CollectionState struct { Db string Coll string Page int64 Limit int64 Count int64 Sort string Filter string // contains filtered or unexported fields }
CollectionState is used to store the state of a collection and use it while rendering doesn't require fetching from the database
func NewCollectionState ¶ added in v0.1.20
func NewCollectionState(db, coll string) *CollectionState
func (*CollectionState) AppendDoc ¶
func (c *CollectionState) AppendDoc(doc primitive.M)
func (*CollectionState) DeleteDoc ¶
func (c *CollectionState) DeleteDoc(id interface{})
func (*CollectionState) GetAllDocs ¶ added in v0.1.4
func (c *CollectionState) GetAllDocs() []primitive.M
func (*CollectionState) GetDocById ¶
func (c *CollectionState) GetDocById(id interface{}) primitive.M
func (*CollectionState) GetJsonDocById ¶
func (c *CollectionState) GetJsonDocById(id interface{}) (string, error)
func (*CollectionState) PopulateDocs ¶
func (c *CollectionState) PopulateDocs(docs []primitive.M)
func (*CollectionState) SetFilter ¶ added in v0.1.10
func (c *CollectionState) SetFilter(filter string)
func (*CollectionState) SetSort ¶ added in v0.1.10
func (c *CollectionState) SetSort(sort string)
func (*CollectionState) UpdateRawDoc ¶
func (c *CollectionState) UpdateRawDoc(doc string) error
type DBsWithCollections ¶
DBsWithCollections is a object used to store the database name and its collections
type Dao ¶
type Dao struct { Config *config.MongoConfig // contains filtered or unexported fields }
func (*Dao) AddCollection ¶
func (*Dao) CreateIndex ¶ added in v0.1.9
func (*Dao) DeleteCollection ¶
func (*Dao) DeleteDocument ¶
func (*Dao) GetDocument ¶
func (*Dao) GetIndexes ¶ added in v0.1.5
GetIndexes fetches the indexes for a given database and collection
func (*Dao) GetServerStatus ¶
func (d *Dao) GetServerStatus(ctx context.Context) (*ServerStatus, error)
func (*Dao) InsetDocument ¶
func (*Dao) ListDbsWithCollections ¶
func (*Dao) ListDocuments ¶
func (*Dao) RenameCollection ¶ added in v0.1.12
type IndexInfo ¶ added in v0.1.5
type IndexInfo struct { Name string Definition bson.M Type string Size string Usage string Properties []string }
IndexInfo represents the combined information about an index from multiple commands
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"` }
ServerStatus are the values chosen from the serverStatus command
type StateMap ¶ added in v0.1.4
type StateMap struct {
// contains filtered or unexported fields
}
StateMap persevere states when hopping between diffrent mongodb servers
func NewStateMap ¶ added in v0.1.4
func NewStateMap() *StateMap
func (*StateMap) AddHiddenColumn ¶ added in v0.1.20
func (*StateMap) GetHiddenColumns ¶ added in v0.1.20
func (*StateMap) ResetHiddenColumns ¶ added in v0.1.20
func (*StateMap) Set ¶ added in v0.1.4
func (sm *StateMap) Set(key string, state *CollectionState)