Documentation ¶
Index ¶
- Constants
- Variables
- func IndexText(key string, weight int) mongo.IndexModel
- func IndexUnique(key string, value bool) mongo.IndexModel
- func StringToBool(value string) bool
- func StringToInt(value string) int
- type Config
- type Error
- type Log
- type Logger
- type Mongo
- func (m *Mongo) CheckSaved(name string, filter primitive.D) bool
- func (m *Mongo) Collection(name string) *mongo.Collection
- func (m *Mongo) Connected() bool
- func (m *Mongo) CreateIndex(name string, indexModel mongo.IndexModel) Error
- func (m *Mongo) Delete(name string, filter primitive.D) Error
- func (m *Mongo) Get(name string, filter primitive.D, opts *options.FindOneOptions) *mongo.SingleResult
- func (m *Mongo) GetURI() string
- func (m *Mongo) Incr(name, key, value string, filter primitive.D) Error
- func (m *Mongo) Paginate(name string, filter primitive.D, limit, page int64, x any) (paginate.PaginationData, Error)
- func (m *Mongo) Save(name string, data any) Error
- func (m *Mongo) Update(name string, filter primitive.D, data primitive.D) Error
- type Schema
- func (s *Schema) CheckSaved() bool
- func (s *Schema) CreateIndex()
- func (s *Schema) Delete() map[string]any
- func (s *Schema) Incr(key, value string) map[string]any
- func (s *Schema) Paginate(filter primitive.D, limit, page int64, x any) mongopagination.PaginationData
- func (s *Schema) Save(data any) map[string]any
- func (s *Schema) SetFilterID(filter primitive.D) *Schema
- func (s *Schema) SetIndex(idx mongo.IndexModel) *Schema
- func (s *Schema) SetMongo(m *Mongo) *Schema
- func (s *Schema) Update(data primitive.D) map[string]any
Constants ¶
View Source
const ( DEFAULT = iota + 100 //100 CONNECT //101 INDEX_CREATE //102 SAVE //103 COUNT //104 UPDATE //105 DELETE //106 GET_CURSOR //107 PAGINATE //108 )
tags
Variables ¶
View Source
var ConfigDefault = Config{
ConnectionURI: "",
Host: "127.0.0.1",
Port: 27017,
Database: "mg_demo",
}
ConfigDefault is the default config
Functions ¶
func IndexUnique ¶
func IndexUnique(key string, value bool) mongo.IndexModel
func StringToBool ¶
func StringToInt ¶
Types ¶
type Config ¶
type Config struct { // Connection string to use for DB. Will override all other authentication values if used // // Optional. Default is "" ConnectionURI string // Host name where the DB is hosted // // Optional. Default is "127.0.0.1" Host string // Port where the DB is listening on // // Optional. Default is 27017 Port int // Server username // // Optional. Default is "" Username string // Server password // // Optional. Default is "" Password string // Database name // // Optional. Default is "fiber" Database string }
Config defines the config for storage.
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
func (*Mongo) Collection ¶
func (m *Mongo) Collection(name string) *mongo.Collection
func (*Mongo) CreateIndex ¶
func (m *Mongo) CreateIndex(name string, indexModel mongo.IndexModel) Error
func (*Mongo) Get ¶
func (m *Mongo) Get(name string, filter primitive.D, opts *options.FindOneOptions) *mongo.SingleResult
type Schema ¶
func (*Schema) CheckSaved ¶
func (*Schema) CreateIndex ¶
func (s *Schema) CreateIndex()
func (*Schema) Paginate ¶
func (s *Schema) Paginate(filter primitive.D, limit, page int64, x any) mongopagination.PaginationData
Click to show internal directories.
Click to hide internal directories.