user

package
v0.0.0-...-1d50e38 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Collection = "users"
)

Variables

View Source
var (
	IdKey           = bsonutil.MustHaveTag(DBUser{}, "Id")
	FirstNameKey    = bsonutil.MustHaveTag(DBUser{}, "FirstName")
	LastNameKey     = bsonutil.MustHaveTag(DBUser{}, "LastName")
	DispNameKey     = bsonutil.MustHaveTag(DBUser{}, "DispName")
	EmailAddressKey = bsonutil.MustHaveTag(DBUser{}, "EmailAddress")
	PatchNumberKey  = bsonutil.MustHaveTag(DBUser{}, "PatchNumber")
	CreatedAtKey    = bsonutil.MustHaveTag(DBUser{}, "CreatedAt")
	SettingsKey     = bsonutil.MustHaveTag(DBUser{}, "Settings")
	APIKeyKey       = bsonutil.MustHaveTag(DBUser{}, "APIKey")
	PubKeysKey      = bsonutil.MustHaveTag(DBUser{}, "PubKeys")
)
View Source
var (
	PubKeyNameKey       = bsonutil.MustHaveTag(PubKey{}, "Name")
	PubKeyKey           = bsonutil.MustHaveTag(PubKey{}, "Key")
	PubKeyNCreatedAtKey = bsonutil.MustHaveTag(PubKey{}, "CreatedAt")
)
View Source
var (
	SettingsTZKey = bsonutil.MustHaveTag(UserSettings{}, "Timezone")
)

Functions

func ById

func ById(userId string) db.Q

func ByIds

func ByIds(userIds ...string) db.Q

func Count

func Count(query db.Q) (int, error)

Count returns the number of user that satisfy the given query.

func UpdateAll

func UpdateAll(query interface{}, update interface{}) error

UpdateAll updates all users.

func UpdateOne

func UpdateOne(query interface{}, update interface{}) error

UpdateOne updates one user.

func UpsertOne

func UpsertOne(query interface{}, update interface{}) (*mgo.ChangeInfo, error)

UpsertOne upserts a user.

Types

type DBUser

type DBUser struct {
	Id           string       `bson:"_id"`
	FirstName    string       `bson:"first_name"`
	LastName     string       `bson:"last_name"`
	DispName     string       `bson:"display_name"`
	EmailAddress string       `bson:"email"`
	PatchNumber  int          `bson:"patch_number"`
	PubKeys      []PubKey     `bson:"public_keys" json:"public_keys"`
	CreatedAt    time.Time    `bson:"created_at"`
	Settings     UserSettings `bson:"settings"`
	APIKey       string       `bson:"apikey"`
}

func Find

func Find(query db.Q) ([]DBUser, error)

Find gets all DBUser for the given query.

func FindOne

func FindOne(query db.Q) (*DBUser, error)

FindOne gets one DBUser for the given query.

func (*DBUser) DisplayName

func (u *DBUser) DisplayName() string

func (*DBUser) Email

func (u *DBUser) Email() string

func (*DBUser) GetAPIKey

func (u *DBUser) GetAPIKey() string

func (*DBUser) GetPublicKey

func (u *DBUser) GetPublicKey(keyname string) (string, error)

func (*DBUser) IncPatchNumber

func (u *DBUser) IncPatchNumber() (int, error)

IncPatchNumber increases the count for the user's patch submissions by one, and then returns the new count.

func (*DBUser) Insert

func (u *DBUser) Insert() error

func (*DBUser) PublicKeys

func (u *DBUser) PublicKeys() []PubKey

func (*DBUser) Username

func (u *DBUser) Username() string

type PubKey

type PubKey struct {
	Name      string    `bson:"name" json:"name"`
	Key       string    `bson:"key" json:"key"`
	CreatedAt time.Time `bson:"created_at" json:"created_at"`
}

type UserSettings

type UserSettings struct {
	Timezone     string `json:"timezone" bson:"timezone"`
	NewWaterfall bool   `json:"new_waterfall" bson:"new_waterfall"`
}

Jump to

Keyboard shortcuts

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