store

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BAD_REQUEST    = "bad request"
	NOT_FOUND      = "not found"
	INTERNAL_ERROR = "internal server error"
)

Functions

This section is empty.

Types

type DB

type DB struct {
	sync.Mutex
	MapStore
}

DB emulatesl a database driver using in-memory data structures.

func (*DB) DeleteAll

func (db *DB) DeleteAll(filter backends.Filter) error

func (*DB) DeleteOne

func (db *DB) DeleteOne(filter backends.Filter) error

func (*DB) GetAll

func (db *DB) GetAll(filter backends.Filter, results interface{}, order string, sorting string, limit int, offset int) (interface{}, error)

func (*DB) GetOne

func (db *DB) GetOne(filter backends.Filter, result interface{}) (interface{}, error)

func (*DB) Save

func (db *DB) Save(object interface{}, filter backends.Filter) (interface{}, error)

type FPToken

type FPToken struct {
	Token   string `form:"token" json:"token" yaml:"token" xml:"token"`
	ExpDate string `form:"expDate" json:"expDate" yaml:"expDate" xml:"expDate"`
}

type MapStore

type MapStore map[string]interface{}

type User

type User struct {
	Users  backends.Repository
	Tokens backends.Repository
}

User wraps User's collections/tables. Implements backneds.Repository interface

func NewDB

func NewDB() User

NewDB initializes a new "DB" with dummy data.

type UserRecord

type UserRecord struct {
	ID bson.ObjectId `json:"id" bson:"_id"`
	// Status of user account
	Active bool `form:"active" json:"active" yaml:"active" xml:"active"`
	// Email of user
	Email string `form:"email" json:"email" yaml:"email" xml:"email"`
	// External id of user
	ExternalID string `form:"externalId,omitempty" json:"externalId,omitempty" yaml:"externalId,omitempty" xml:"externalId,omitempty"`
	// List of namespaces this user belongs to
	Namespaces []string `form:"namespaces,omitempty" json:"namespaces,omitempty" yaml:"namespaces,omitempty" xml:"namespaces,omitempty"`
	// List of organizations to which this user belongs to
	Organizations []string `form:"organizations,omitempty" json:"organizations,omitempty" yaml:"organizations,omitempty" xml:"organizations,omitempty"`
	// Password of user
	Password string `form:"password,omitempty" json:"password,omitempty" yaml:"password,omitempty" xml:"password,omitempty"`
	// Roles of user
	Roles []string `form:"roles,omitempty" json:"roles,omitempty" yaml:"roles,omitempty" xml:"roles,omitempty"`
	// Token for email verification
	Token string `form:"token,omitempty" json:"token,omitempty" yaml:"token,omitempty" xml:"token,omitempty"`
	// Tokens for forgotten password
	FPToken FPToken `form:"forgotPasswordTokens" json:"forgotPasswordTokens" yaml:"forgotPasswordTokens" xml:"forgotPasswordTokens"`
	// Time of creating
	CreatedAt int64 `json:"createdAt,omitempty" bson:"createdAt"`
	// Time of modifying
	ModifiedAt int64 `json:"modifiedAt,omitempty" bson:"modifiedAt"`
}

func (*UserRecord) ToAppUsers

func (u *UserRecord) ToAppUsers() *app.Users

Jump to

Keyboard shortcuts

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