Documentation ¶
Index ¶
- func AssignMIne(key string, value bson.M, parent bson.M) bson.M
- func AssignStrIne(key, value string, parent bson.M) bson.M
- func BetweenTime(field string, start, end time.Time, m bson.M) bson.M
- func BetweenTimeD(field string, start, end time.Time, d bson.D) bson.D
- func CollectionExists(db *mongo.Database, coll string) (bool, error)
- func CreateIndex(coll *mongo.Collection, imodels []mongo.IndexModel) error
- func CreateIndexIfNotExists(db *mongo.Database, collname string, indexes map[string]string) (bool, error)
- func DialCollection(db *mongo.Database, name string) *mongo.Collection
- func NullableString(s string) interface{}
- func TakeClient(dsn string) (*mongo.Client, error)
- func TakeDatabase(dsn string) (*mongo.Database, *mongo.Client, error)
- type BaseModel
- func (b *BaseModel) Aggregate(pipeline []bson.M) (interface{}, error)
- func (b *BaseModel) Clear() error
- func (b *BaseModel) Count(id string) (int64, error)
- func (b *BaseModel) CountWhere(where bson.M) (int64, error)
- func (b *BaseModel) CountWhereD(where bson.D) (int64, error)
- func (b *BaseModel) Delete(id string) (int64, error)
- func (b *BaseModel) DeleteWhere(where bson.M) (int64, error)
- func (b *BaseModel) DeleteWhereD(where bson.D) (int64, error)
- func (b *BaseModel) Exists(id string) (bool, error)
- func (b *BaseModel) ExistsWhere(where bson.M) (bool, error)
- func (b *BaseModel) ExistsWhereD(where bson.D) (bool, error)
- func (b *BaseModel) Find(id string) (interface{}, error)
- func (b *BaseModel) FindWhere(where bson.M) (interface{}, error)
- func (b *BaseModel) FindWhereD(where bson.D) (interface{}, error)
- func (b *BaseModel) Insert(v interface{}) (string, error)
- func (b *BaseModel) InsertMany(v []interface{}) error
- func (b *BaseModel) QueryWhere(where bson.M) (interface{}, error)
- func (b *BaseModel) QueryWhereD(where bson.D) (interface{}, error)
- func (b *BaseModel) SumWhere(match bson.M, field string) (float64, error)
- func (b *BaseModel) Update(id string, updator bson.M) (int64, error)
- func (b *BaseModel) UpdateSet(id string, updater bson.M) (int64, error)
- func (b *BaseModel) UpdateWhere(where bson.M, updator interface{}) (int64, error)
- func (b *BaseModel) UpdateWhereD(where bson.D, updator interface{}) (int64, error)
- type GroupCountClass
- type Index
- type SumClass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssignMIne ¶ added in v1.0.10
AssignMIne Assign bson.M if value is not empty
func AssignStrIne ¶ added in v1.0.9
AssignStrIne Assign string if value is not empty
func CollectionExists ¶
CollectionExists check if collection exists
func CreateIndex ¶
func CreateIndex(coll *mongo.Collection, imodels []mongo.IndexModel) error
CreateIndex creates indexes for coll
func CreateIndexIfNotExists ¶
func CreateIndexIfNotExists(db *mongo.Database, collname string, indexes map[string]string) (bool, error)
CreateIndexIfNotExists create indexes if collection doesn't exists
func DialCollection ¶
func DialCollection(db *mongo.Database, name string) *mongo.Collection
DialCollection DialCollection
func NullableString ¶ added in v1.0.8
func NullableString(s string) interface{}
Types ¶
type BaseModel ¶
type BaseModel struct { DataSourceName string //data source name CollectionName string // collection name Type reflect.Type Data interface{} Client *mongo.Client Database *mongo.Database Collection *mongo.Collection }
func NewBaseModel ¶
func NewBaseModelWithCreated ¶
func (*BaseModel) InsertMany ¶
func (*BaseModel) UpdateWhere ¶
type GroupCountClass ¶ added in v1.0.7
Click to show internal directories.
Click to hide internal directories.