user

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

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

Go to latest
Published: Dec 12, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, traceID string, dbSes *mgo.Session, userID string) error

Delete removes a user from the database.

func Update

func Update(ctx context.Context, traceID string, dbSes *mgo.Session, userID string, cu *CreateUser) error

Update replaces a user document in the database.

Types

type Address

type Address struct {
	Type         int        `bson:"type" json:"type" validate:"required"`
	LineOne      string     `bson:"line_one" json:"line_one" validate:"required"`
	LineTwo      string     `bson:"line_two" json:"line_two,omitempty"`
	City         string     `bson:"city" json:"city" validate:"required"`
	State        string     `bson:"state" json:"state" validate:"required"`
	Zipcode      string     `bson:"zipcode" json:"zipcode" validate:"required"`
	Phone        string     `bson:"phone" json:"phone" validate:"required"`
	DateModified *time.Time `bson:"date_modified" json:"date_modified"`
	DateCreated  *time.Time `bson:"date_created,omitempty" json:"date_created"`
}

Address contains information about a user's address.

type CreateAddress

type CreateAddress struct {
	Type         int        `bson:"type" json:"type" validate:"required"`
	LineOne      string     `bson:"line_one" json:"line_one" validate:"required"`
	LineTwo      string     `bson:"line_two" json:"line_two,omitempty"`
	City         string     `bson:"city" json:"city" validate:"required"`
	State        string     `bson:"state" json:"state" validate:"required"`
	Zipcode      string     `bson:"zipcode" json:"zipcode" validate:"required"`
	Phone        string     `bson:"phone" json:"phone" validate:"required"`
	DateModified *time.Time `bson:"date_modified" json:"-"`
}

CreateAddress contains information about a user's address.

type CreateUser

type CreateUser struct {
	UserType     int             `bson:"type" json:"type" validate:"required"`
	FirstName    string          `bson:"first_name" json:"first_name" validate:"required"`
	LastName     string          `bson:"last_name" json:"last_name" validate:"required"`
	Email        string          `bson:"email" json:"email" validate:"required"`
	Company      string          `bson:"company" json:"company" validate:"required"`
	Addresses    []CreateAddress `bson:"addresses" json:"addresses" validate:"required"`
	DateModified *time.Time      `bson:"date_modified" json:"-"`
}

CreateUser contains information about a user.

type User

type User struct {
	UserID       string     `bson:"user_id,omitempty" json:"user_id,omitempty"`
	UserType     int        `bson:"type" json:"type"`
	FirstName    string     `bson:"first_name" json:"first_name"`
	LastName     string     `bson:"last_name" json:"last_name"`
	Email        string     `bson:"email" json:"email"`
	Company      string     `bson:"company" json:"company"`
	Addresses    []Address  `bson:"addresses" json:"addresses"`
	DateModified *time.Time `bson:"date_modified" json:"date_modified"`
	DateCreated  *time.Time `bson:"date_created,omitempty" json:"date_created"`
}

User contains information about a user.

func Create

func Create(ctx context.Context, traceID string, dbSes *mgo.Session, cu *CreateUser) (*User, error)

Create inserts a new user into the database.

func List

func List(ctx context.Context, traceID string, dbSes *mgo.Session) ([]User, error)

List retrieves a list of existing users from the database.

func Retrieve

func Retrieve(ctx context.Context, traceID string, dbSes *mgo.Session, userID string) (*User, error)

Retrieve gets the specified user from the database.

Jump to

Keyboard shortcuts

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