organization

package
v0.0.0-...-3bd2bae Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound abstracts the  not found error.
	ErrNotFound = errors.New("Entity not found")

	// ErrInvalidID occurs when an ID is not in a valid form.
	ErrInvalidID = errors.New("ID is not in its proper form")

	// ErrAuthenticationFailure occurs when a user attempts to authenticate but
	// anything goes wrong.
	ErrAuthenticationFailure = errors.New("Authentication failed")

	// ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies.
	ErrForbidden = errors.New("Attempted action is not allowed")
)

Functions

func Delete

func Delete(ctx context.Context, dbConn *db.MongoDB, id string) error

Delete removes a user from the database.

func EnsureIndex

func EnsureIndex(ctx context.Context, dbConn *db.MongoDB) error

func InsertMember

func InsertMember(ctx context.Context, dbConn *db.MongoDB, id string, member *Member) error

InsertMember adds a member

func RemoveMember

func RemoveMember(ctx context.Context, dbConn *db.MongoDB, id string, memberId string) error

RemoveMember removes a member from an organization

func Update

func Update(ctx context.Context, dbConn *db.MongoDB, id string, upd *UpdOrg, now time.Time) error

Update replaces a organization document in the database.

func UpdateMember

func UpdateMember(ctx context.Context, dbConn *db.MongoDB, id string, member *Member) error

UpdateMember updates a member

Types

type Member

type Member struct {
	ID     string `json:"id,omitempty"`
	Nonce  string `json:"nonce,omitempty"`
	Status string `json:"status,omitempty"`
	Role   string `json:"role,omitempty"`
	Email  string `json:"email,omitempty"`
}

type NewOrg

type NewOrg struct {
	Name    string `json:"name" validate:"required"`
	Email   string `json:"email" validate:"required"`
	Country string `json:"country" validate:"required"`
}

type Organization

type Organization struct {
	ID primitive.ObjectID `bson:"_id" json:"id"`

	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
	Deleted   bool      `json:"-" bson:"deleted"`

	Name       string    `json:"name" bson:"name"`
	Industry   string    `json:"industry" bson:"industry"`
	Type       string    `json:"type,omitempty" bson:"type,omitempty"`
	Size       string    `json:"size,omitempty" bson:"size,omitempty"`
	Email      string    `json:"email" bson:"email,omitempty"`
	Phone      string    `json:"phone" bson:"phone,omitempty"`
	ScreenName string    `json:"screenName,omitempty" bson:"screenName,omitempty"`
	URL        string    `json:"url,omitempty" bson:"url,omitempty"`
	Country    string    `json:"country,omitempty" bson:"country,omitempty"`
	City       string    `json:"city,omitempty" bson:"city,omitempty"`
	Language   string    `bson:"language,omitempty" json:"language,omitempty"`
	Timezone   string    `bson:"timezone,omitempty" json:"timezone,omitempty"`
	Seats      int       `bson:"seats" json:"seats"`
	Members    []*Member `json:"members" bson:"members"`
}

Organization Model

func Create

func Create(ctx context.Context, dbConn *db.MongoDB, nu *Organization, now time.Time) (*Organization, error)

Create inserts a new user into the database.

func Get

func Get(ctx context.Context, dbConn *db.MongoDB, id string) (*Organization, error)

Get gets the specified user from the database.

func List

func List(ctx context.Context, dbConn *db.MongoDB, optionsList ...func(*db.ListOpts)) ([]*Organization, error)

List retrieves a list of existing organization from the database.

type UpdOrg

type UpdOrg struct {
	Name       *string `json:"name,omitempty" bson:"name,omitempty"`
	Industry   *string `json:"industry,omitempty" bson:"industry,omitempty"`
	Type       *string `json:"type,omitempty" bson:"type,omitempty"`
	Size       *string `json:"size,omitempty" bson:"size,omitempty"`
	Email      *string `json:"email,omitempty" bson:"email,omitempty"`
	Phone      *string `json:"phone,omitempty" bson:"phone,omitempty"`
	ScreenName *string `json:"screenName,omitempty" bson:"screenName,omitempty"`
	URL        *string `json:"url,omitempty" bson:"url,omitempty"`
	Country    *string `json:"country,omitempty" bson:"country,omitempty"`
	City       *string `json:"city,omitempty" bson:"city,omitempty"`
	Language   *string `bson:"language,omitempty" json:"language,omitempty"`
	Timezone   *string `bson:"timezone,omitempty" json:"timezone,omitempty"`

	Members []*Member `json:"members" bson:"members"`
}

Jump to

Keyboard shortcuts

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