user

package
v2.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserBlogMgoFieldID      = "_id"
	UserBlogMgoFieldUserId  = "uid"
	UserBlogMgoFieldBlogId  = "bid"
	UserBlogMgoFieldContent = "Content"
)
View Source
const (
	UserMgoFieldID           = "_id"
	UserMgoFieldUserId       = "uid"
	UserMgoFieldUsername     = "Username"
	UserMgoFieldAge          = "Age"
	UserMgoFieldRegisterDate = "registerDate"
)

Variables

View Source
var (
	UserBlogMgoSortFieldIDAsc  = primitive.E{Key: "_id", Value: 1}
	UserBlogMgoSortFieldIDDesc = 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}
	UserMgoSortFieldRegisterDateAsc  = primitive.E{Key: "registerDate", Value: 1}
	UserMgoSortFieldRegisterDateDesc = primitive.E{Key: "registerDate", Value: -1}
)
View Source
var UserBlogIndexKey_UserId = bson.D{
	{Key: "UserId", Value: 1},
}
View Source
var UserBlogIndexes = []mongo.IndexModel{
	{
		Keys: UserBlogIndexKey_UserId,
	},
}
View Source
var UserBlogIndexesFunc = func() {
	orm.SetupIndexModel(Col("test_user_blog"), UserBlogIndexes)
}
View Source
var UserBlogMgr *_UserBlogMgr
View Source
var UserIndexKey_Age = bson.D{
	{Key: "Age", Value: 1},
}
View Source
var UserIndexKey_RegisterDate = bson.D{
	{Key: "RegisterDate", Value: 1},
}
View Source
var UserIndexKey_Username = bson.D{
	{Key: "Username", Value: 1},
}
View Source
var UserIndexKey_UsernameAge = bson.D{
	{Key: "Username", Value: 1},
	{Key: "Age", Value: 1},
}
View Source
var UserIndexes = []mongo.IndexModel{
	{
		Keys: UserIndexKey_UsernameAge,
	},
	{
		Keys: UserIndexKey_Username,
	},
	{
		Keys: UserIndexKey_Age,
	},
	{
		Keys: UserIndexKey_RegisterDate,
	},
}
View Source
var UserIndexesFunc = func() {
	orm.SetupIndexModel(Col("test_user"), UserIndexes)
}
View Source
var UserMgr *_UserMgr

Functions

func Col

func Col(col string) *mongo.Collection

func Get_UserBlogMgr added in v2.5.5

func Get_UserBlogMgr() *_UserBlogMgr

Get_UserBlogMgr 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 UserAddInsertCallback(cb func(obj orm.EzOrmObj))

func UserAddUpdateCallback

func UserAddUpdateCallback(cb func(obj orm.EzOrmObj))

func UserBlogAddInsertCallback added in v2.5.5

func UserBlogAddInsertCallback(cb func(obj orm.EzOrmObj))

func UserBlogAddUpdateCallback added in v2.5.5

func UserBlogAddUpdateCallback(cb func(obj orm.EzOrmObj))

func UserBlogInsertCallback added in v2.5.5

func UserBlogInsertCallback(o *UserBlog)

func UserBlogUpdateCallback added in v2.5.5

func UserBlogUpdateCallback(o *UserBlog)

func UserInsertCallback

func UserInsertCallback(o *User)

func UserUpdateCallback

func UserUpdateCallback(o *User)

Types

type SetupOption added in v2.0.1

type SetupOption struct {
	// contains filtered or unexported fields
}

type SetupOptionFn added in v2.0.1

type SetupOptionFn func(opts *SetupOption)

func WithPostHooks added in v2.4.7

func WithPostHooks(fn ...func()) SetupOptionFn

func WithPrometheusMonitor added in v2.0.1

func WithPrometheusMonitor(app, gatewayAddress string) SetupOptionFn

func WithStatsDMonitor added in v2.0.1

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"`
	RegisterDate time.Time `bson:"registerDate" json:"registerDate"`
	// contains filtered or unexported fields
}

User all registered user use our systems

func (*User) FindOneAndSave added in v2.8.3

func (o *User) FindOneAndSave(ctx context.Context, query interface{}) (*mongo.SingleResult, error)

FindOneAndSave try to find one doc by `query`, and then upsert the result with the current object

func (*User) GetClassName

func (p *User) GetClassName() string

func (*User) GetNameSpace

func (p *User) GetNameSpace() string

func (*User) Id

func (o *User) Id() string

func (*User) InsertUnique

func (o *User) InsertUnique(ctx context.Context, query interface{}) (saved bool, err error)

func (*User) Save

func (o *User) Save(ctx context.Context) (*mongo.UpdateResult, error)

Save upserts the document , Save itself is concurrent-safe , but maybe it is not atomic together with other operations, such as `Find`

type UserBlog added in v2.5.5

type UserBlog struct {
	ID primitive.ObjectID `json:"id" bson:"_id,omitempty"`

	// the identity of each user
	UserId uint64 `bson:"uid" json:"uid"`

	// the identity of each blog
	BlogId  uint64 `bson:"bid" json:"bid"`
	Content string `bson:"Content" json:"Content"`
	// contains filtered or unexported fields
}

func (*UserBlog) FindOneAndSave added in v2.8.3

func (o *UserBlog) FindOneAndSave(ctx context.Context, query interface{}) (*mongo.SingleResult, error)

FindOneAndSave try to find one doc by `query`, and then upsert the result with the current object

func (*UserBlog) GetClassName added in v2.5.5

func (p *UserBlog) GetClassName() string

func (*UserBlog) GetNameSpace added in v2.5.5

func (p *UserBlog) GetNameSpace() string

func (*UserBlog) Id added in v2.5.5

func (o *UserBlog) Id() string

func (*UserBlog) InsertUnique added in v2.5.5

func (o *UserBlog) InsertUnique(ctx context.Context, query interface{}) (saved bool, err error)

func (*UserBlog) Save added in v2.5.5

func (o *UserBlog) Save(ctx context.Context) (*mongo.UpdateResult, error)

Save upserts the document , Save itself is concurrent-safe , but maybe it is not atomic together with other operations, such as `Find`

type UserBlogMgoSortField_WRP added in v2.5.5

type UserBlogMgoSortField_WRP = primitive.D

UserBlogMgoSortField_WRP is a wrapper of UserBlog sort fields e.g.: UserBlogMgoSortField_WRP{UserBlogMgoSortField_X_Asc, UserBlogMgoSortField_Y_DESC}

type UserMgoSortField_WRP

type UserMgoSortField_WRP = primitive.D

UserMgoSortField_WRP is a wrapper of User sort fields e.g.: UserMgoSortField_WRP{UserMgoSortField_X_Asc, UserMgoSortField_Y_DESC}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL