db

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendUserService

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

func (*BackendUserService) GetUserProfile

func (r *BackendUserService) GetUserProfile(userID string) (*app.UserProfile, error)

GetUserProfile finds user profile by Id. Return media type if succeed.

func (*BackendUserService) UpdateUserProfile

func (r *BackendUserService) UpdateUserProfile(profile *app.UserProfilePayload, userID string) (*app.UserProfile, error)

UpdateUserProfile updates user profile by id. Return media type if succeed.

type DB

type DB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func New

func New() *DB

New initializes a new "DB" with dummy data.

func (*DB) GetUserProfile

func (db *DB) GetUserProfile(objectID string) (*app.UserProfile, error)

GetUserProfile mock implementation

func (*DB) UpdateMyProfile

func (db *DB) UpdateMyProfile(profile *app.UserProfilePayload, userID string) (*app.UserProfile, error)

UpdateMyProfile mock implementation

func (*DB) UpdateUserProfile

func (db *DB) UpdateUserProfile(profile *app.UserProfilePayload, userID string) (*app.UserProfile, error)

UpdateUserProfile mock implementation

type User

type User struct {
	UserID                    string `json:"userId" bson:"userId"`
	FullName                  string `json:"fullname,omitempty" bson:"fullName,omitempty"`
	Email                     string `json:"email,omitempty" bson:"email,omitempty"`
	Company                   string `json:"company,omitempty" bson:"company,omitempty"`
	CompanyRegistrationNumber string `json:"companyRegistrationNumber,omitempty" bson:"companyRegistrationNumber,omitempty"`
	TaxNumber                 string `json:"taxNumber,omitempty" bson:"taxNumber,omitempty"`
	CreatedOn                 int    `json:"createdOn,omitempty" bson:"createdOn"`
}

User is an object which holds the UserID, FullName, Email and the date of creation

type UserProfileRepository

type UserProfileRepository interface {
	// GetUserProfile looks up a UserProfile by the user ID.
	GetUserProfile(userID string) (*app.UserProfile, error)
	// UpdateUserProfile updates the UserProfile data for a particular user by its user ID.
	// If the profile already exists, it updates the data. If not profile entry exists, a new one is created.
	// Returns the updated or newly created user profile.
	UpdateUserProfile(profile *app.UserProfilePayload, userID string) (*app.UserProfile, error)
}

UserProfileRepository defines the interface for accessing the user profile data

func NewUserService

func NewUserService(userRepository backends.Repository) UserProfileRepository

Jump to

Keyboard shortcuts

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