base

package
v0.0.0-...-8f4c613 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionUser = "users"
)

Variables

This section is empty.

Functions

func DeleteUserByID

func DeleteUserByID(id string) error

func ExistUserByID

func ExistUserByID(id string) (bool, error)

func ExistUserByQuery

func ExistUserByQuery(query interface{}) (bool, error)

func GetSessionAndCollection

func GetSessionAndCollection(collection string) (*mgo.Session, *mgo.Collection)

func GetSessionAndGridFS

func GetSessionAndGridFS(prefix string) (*mgo.Session, *mgo.GridFS)

func UpdateUser

func UpdateUser(selector interface{}, user *User) error

func UpdateUserAll

func UpdateUserAll(selector interface{}, user *User) (*mgo.ChangeInfo, error)

func UpdateUserByID

func UpdateUserByID(id string, user *User) error

Types

type DB

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

func NewDB

func NewDB(name string) *DB

func (*DB) InitDB

func (db *DB) InitDB(session *mgo.Session)

type User

type User struct {
	ID        bson.ObjectId `bson:"_id" json:"_id"`
	UserName  string        `bson:"user_name" json:"user_name,omitempty" valid:"required~first name is blank"`
	Email     string        `bson:"email" json:"email,omitempty" valid:"required,email"`
	Password  string        `bson:"password" json:"password,omitempty" valid:"required"`
	CreatedAt int64         `bson:"created_at" json:"created_at"`
	UpdatedAt int64         `bson:"updated_at" json:"updated_at"`
}

func FindAllUserByQuery

func FindAllUserByQuery(query interface{}) ([]*User, error)

func FindUserByID

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

func FindUserByQuery

func FindUserByQuery(query interface{}) (*User, error)

func NewUser

func NewUser() *User

func (*User) Insert

func (user *User) Insert() error

Jump to

Keyboard shortcuts

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