gengouser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Code generated by gotoc_mongo. DO NOT EDIT. gotoc version: 0.0.3 source: samples/mongo/user.mongo.gtc

Index

Constants

View Source
const (
	UserName       = "name"
	UserPassword   = "password"
	UserEmail      = "email"
	UserCredits    = "credits"
	UserManId      = "manId"
	UserCreateDate = "createDate"
)

mongodb fields name for user

View Source
const (
	UserNameDesc       = "-name"
	UserPasswordDesc   = "-password"
	UserEmailDesc      = "-email"
	UserCreditsDesc    = "-credits"
	UserManIdDesc      = "-manId"
	UserCreateDateDesc = "-createDate"
)

mongodb fields DESC name(for sort) for user

View Source
const (
	LogUserId = "userId"
	LogType   = "type"
	LogEvent  = "event"
)

mongodb fields name for user_log

View Source
const (
	LogUserIdDesc = "-userId"
	LogTypeDesc   = "-type"
	LogEventDesc  = "-event"
)

mongodb fields DESC name(for sort) for user_log

View Source
const ColLogName = "user_log"
View Source
const ColUserName = "user"
View Source
const TestName = "test"

Variables

This section is empty.

Functions

func EnsureLogKeys

func EnsureLogKeys()

EnsureLogKeys ensures keys for user_log

func EnsureUserKeys

func EnsureUserKeys()

EnsureUserKeys ensures keys for user

func GetTestCol

func GetTestCol(colName string) (*mgo.Session, *mgo.Collection)

func InitTest

func InitTest(getter mgoimpl.SessionGetter)

func RemoveLogById

func RemoveLogById(id string) error

RemoveLogById remove objects in mongodb by id

func RemoveUserById

func RemoveUserById(id string) error

RemoveUserById remove objects in mongodb by id

Types

type Log

type Log struct {
	// ID for user_log
	ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
	// 用户id
	UserId string `json:"userId" bson:"userId"`
	// 类型
	Type int32 `json:"type" bson:"type"`
	// 发生的事件
	Event []string `json:"event" bson:"event"`
}

Log 用户日志表

func FindLogById

func FindLogById(id string) (*Log, error)

FindLogById get object from mongodb by id

func NewLog

func NewLog() *Log

NewLog create a new Log instance

func (*Log) Id

func (o *Log) Id() string

Id returns ID as hex string

func (*Log) Remove

func (o *Log) Remove() error

Remove object in mongodb

func (*Log) Save

func (o *Log) Save() (*mgo.ChangeInfo, error)

Save object in mongodb by upsert

type QueryLogContext

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

QueryLogContext is used to implement query operation

func QueryLog

func QueryLog(filter interface{}) *QueryLogContext

QueryLog create a new query context instance

func (*QueryLogContext) Batch

func (c *QueryLogContext) Batch(b int) *QueryLogContext

Batch set batch size

func (*QueryLogContext) Count

func (c *QueryLogContext) Count() (int, error)

Count result

func (*QueryLogContext) Find

func (c *QueryLogContext) Find() (os []*Log, err error)

Find results

func (*QueryLogContext) FindOne

func (c *QueryLogContext) FindOne() (o *Log, err error)

FindOne result

func (*QueryLogContext) Limit

func (c *QueryLogContext) Limit(offset, limit int) *QueryLogContext

Limit set offset and limit

func (*QueryLogContext) Select

func (c *QueryLogContext) Select(selectFields ...string) *QueryLogContext

Select set select fields

func (*QueryLogContext) Sort

func (c *QueryLogContext) Sort(sortFields ...string) *QueryLogContext

Sort set sort fields

func (*QueryLogContext) Timeout

Timeout set query timeout

func (*QueryLogContext) Walk

func (c *QueryLogContext) Walk(walkFunc func(*Log) error) error

Walk results

type QueryUserContext

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

QueryUserContext is used to implement query operation

func QueryUser

func QueryUser(filter interface{}) *QueryUserContext

QueryUser create a new query context instance

func (*QueryUserContext) Batch

func (c *QueryUserContext) Batch(b int) *QueryUserContext

Batch set batch size

func (*QueryUserContext) Count

func (c *QueryUserContext) Count() (int, error)

Count result

func (*QueryUserContext) Find

func (c *QueryUserContext) Find() (os []*User, err error)

Find results

func (*QueryUserContext) FindOne

func (c *QueryUserContext) FindOne() (o *User, err error)

FindOne result

func (*QueryUserContext) Limit

func (c *QueryUserContext) Limit(offset, limit int) *QueryUserContext

Limit set offset and limit

func (*QueryUserContext) Select

func (c *QueryUserContext) Select(selectFields ...string) *QueryUserContext

Select set select fields

func (*QueryUserContext) Sort

func (c *QueryUserContext) Sort(sortFields ...string) *QueryUserContext

Sort set sort fields

func (*QueryUserContext) Timeout

Timeout set query timeout

func (*QueryUserContext) Walk

func (c *QueryUserContext) Walk(walkFunc func(*User) error) error

Walk results

type User

type User struct {
	// ID for user
	ID bson.ObjectId `json:"id" bson:"_id,omitempty"`
	// 用户名
	Name string `json:"name" bson:"name"`
	// 用户密码
	Password string `json:"password" bson:"password"`
	// 用户邮箱
	Email string `json:"email" bson:"email"`
	// 用户信用记录
	Credits []string `json:"credits" bson:"credits"`
	//
	ManId int64 `json:"manId" bson:"manId"`
	//
	CreateDate int64 `json:"createDate" bson:"createDate"`
}

User 用户表

func FindUserById

func FindUserById(id string) (*User, error)

FindUserById get object from mongodb by id

func NewUser

func NewUser() *User

NewUser create a new User instance

func (*User) Id

func (o *User) Id() string

Id returns ID as hex string

func (*User) Remove

func (o *User) Remove() error

Remove object in mongodb

func (*User) Save

func (o *User) Save() (*mgo.ChangeInfo, error)

Save object in mongodb by upsert

Jump to

Keyboard shortcuts

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