nested

package
v2.8.3 Latest Latest
Warning

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

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

Documentation

Index

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

func UserAddUpdateCallback

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

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 (p *Blog) GetClassName() string

func (*Blog) GetNameSpace

func (p *Blog) GetNameSpace() string

type BlogMgoSortField_WRP

type BlogMgoSortField_WRP = primitive.D

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

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 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