Documentation ¶
Index ¶
- Constants
- Variables
- func Col(col string) *mongo.Collection
- func Get_BlogMgr() *_BlogMgr
- func Get_UserMgr() *_UserMgr
- func MgoSetup(config *db.MongoConfig, opts ...SetupOptionFn)
- func UserAddInsertCallback(cb func(obj orm.EzOrmObj))
- func UserAddUpdateCallback(cb func(obj orm.EzOrmObj))
- func UserInsertCallback(o *User)
- func UserUpdateCallback(o *User)
- type Blog
- type BlogMgoSortField_WRP
- type SetupOption
- type SetupOptionFn
- type User
- func (o *User) FindOneAndSave(ctx context.Context, query interface{}) (*mongo.SingleResult, error)
- func (p *User) GetClassName() string
- func (p *User) GetNameSpace() string
- func (o *User) Id() string
- func (o *User) InsertUnique(ctx context.Context, query interface{}) (saved bool, err error)
- func (o *User) Save(ctx context.Context) (*mongo.UpdateResult, error)
- type UserMgoSortField_WRP
Constants ¶
View Source
const ( BlogMgoFieldID = "_id" BlogMgoFieldBlogId = "bid" )
View Source
const ( UserMgoFieldID = "_id" UserMgoFieldUserId = "uid" UserMgoFieldUsername = "Username" UserMgoFieldAge = "Age" UserMgoFieldBlogs = "Blogs" UserMgoFieldRegisterDate = "registerDate" )
Variables ¶
View Source
var ( BlogMgoSortFieldIDAsc = primitive.E{Key: "_id", Value: 1} BlogMgoSortFieldIDDesc = primitive.E{Key: "_id", Value: -1} )
View Source
var ( UserMgoSortFieldIDAsc = primitive.E{Key: "_id", Value: 1} UserMgoSortFieldIDDesc = primitive.E{Key: "_id", Value: -1} UserMgoSortFieldAgeAsc = primitive.E{Key: "Age", Value: 1} UserMgoSortFieldAgeDesc = primitive.E{Key: "Age", Value: -1} )
View Source
var BlogMgr *_BlogMgr
View Source
var UserIndexKey_Age = bson.D{
{Key: "Age", Value: 1},
}
View Source
var UserIndexKey_Username = bson.D{
{Key: "Username", Value: 1},
}
View Source
var UserIndexes = []mongo.IndexModel{ { Keys: UserIndexKey_Username, }, { Keys: UserIndexKey_Age, }, }
View Source
var UserIndexesFunc = func() { orm.SetupIndexModel(Col("mongo_e2e.User"), UserIndexes) }
View Source
var UserMgr *_UserMgr
Functions ¶
func Col ¶
func Col(col string) *mongo.Collection
func Get_BlogMgr ¶
func Get_BlogMgr() *_BlogMgr
Get_BlogMgr returns the orm manager in case of its name starts with lower letter
func Get_UserMgr ¶
func Get_UserMgr() *_UserMgr
Get_UserMgr returns the orm manager in case of its name starts with lower letter
func MgoSetup ¶
func MgoSetup(config *db.MongoConfig, opts ...SetupOptionFn)
func UserAddInsertCallback ¶
func UserAddUpdateCallback ¶
func UserInsertCallback ¶
func UserInsertCallback(o *User)
func UserUpdateCallback ¶
func UserUpdateCallback(o *User)
Types ¶
type Blog ¶
type Blog struct { ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` BlogId uint64 `bson:"bid" json:"bid"` // contains filtered or unexported fields }
func (*Blog) GetClassName ¶
func (*Blog) GetNameSpace ¶
type BlogMgoSortField_WRP ¶
BlogMgoSortField_WRP is a wrapper of Blog sort fields e.g.: BlogMgoSortField_WRP{BlogMgoSortField_X_Asc, BlogMgoSortField_Y_DESC}
type SetupOption ¶
type SetupOption struct {
// contains filtered or unexported fields
}
type SetupOptionFn ¶
type SetupOptionFn func(opts *SetupOption)
func WithPostHooks ¶ added in v2.4.7
func WithPostHooks(fn ...func()) SetupOptionFn
func WithPrometheusMonitor ¶
func WithPrometheusMonitor(app, gatewayAddress string) SetupOptionFn
func WithStatsDMonitor ¶
func WithStatsDMonitor(app string) SetupOptionFn
type User ¶
type User struct { ID primitive.ObjectID `json:"id" bson:"_id,omitempty"` // the identity of each user UserId uint64 `bson:"uid" json:"uid"` // name of user used to login Username string `bson:"Username" json:"Username"` Age int32 `bson:"Age" json:"Age"` Blogs []Blog `bson:"Blogs" json:"Blogs"` RegisterDate time.Time `bson:"registerDate" json:"registerDate"` // contains filtered or unexported fields }
func (*User) FindOneAndSave ¶ added in v2.8.3
FindOneAndSave try to find one doc by `query`, and then upsert the result with the current object
func (*User) GetClassName ¶
func (*User) GetNameSpace ¶
func (*User) InsertUnique ¶
type UserMgoSortField_WRP ¶
UserMgoSortField_WRP is a wrapper of User sort fields e.g.: UserMgoSortField_WRP{UserMgoSortField_X_Asc, UserMgoSortField_Y_DESC}
Click to show internal directories.
Click to hide internal directories.