mongodoc

package
v0.0.0-...-5cbc45b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidObject = rerror.NewE(i18n.T("invalid object"))
	ErrInvalidDoc    = rerror.NewE(i18n.T("invalid document"))
)

Functions

func ModelFrom

func ModelFrom(obj Document) (res any, err error)

func NewConsumer

func NewConsumer[T Model[U], U any]() *mongox.SliceFuncConsumer[T, U]

Types

type Document

type Document struct {
	Type   Type
	Object bson.Raw
}

func NewDocument

func NewDocument(obj any) (doc Document, id string, err error)

type Model

type Model[T any] interface {
	Model() (T, error)
}

type PasswordResetDocument

type PasswordResetDocument struct {
	Token     string
	CreatedAt time.Time
}

func (*PasswordResetDocument) Model

type Type

type Type string

type UserConsumer

type UserConsumer = mongox.SliceFuncConsumer[*UserDocument, *user.User]

func NewUserConsumer

func NewUserConsumer(host string) *UserConsumer

type UserDocument

type UserDocument struct {
	ID            string
	Name          string
	Email         string
	Subs          []string
	Workspace     string
	Team          string `bson:",omitempty"`
	Lang          string
	Theme         string
	Password      []byte
	PasswordReset *PasswordResetDocument
	Verification  *UserVerificationDoc
}

func NewUser

func NewUser(user *user.User) (*UserDocument, string)

func (*UserDocument) Model

func (d *UserDocument) Model() (*user.User, error)

type UserVerificationDoc

type UserVerificationDoc struct {
	Code       string
	Expiration time.Time
	Verified   bool
}

type WorkspaceConsumer

func NewWorkspaceConsumer

func NewWorkspaceConsumer() *WorkspaceConsumer

type WorkspaceDocument

type WorkspaceDocument struct {
	ID           string
	Name         string
	Members      map[string]WorkspaceMemberDocument
	Integrations map[string]WorkspaceMemberDocument
	Personal     bool
	Policy       string `bson:",omitempty"`
}

func NewWorkspace

func NewWorkspace(ws *workspace.Workspace) (*WorkspaceDocument, string)

func NewWorkspaces

func NewWorkspaces(workspaces []*workspace.Workspace) ([]*WorkspaceDocument, []string)

func (*WorkspaceDocument) Model

func (d *WorkspaceDocument) Model() (*workspace.Workspace, error)

type WorkspaceMemberDocument

type WorkspaceMemberDocument struct {
	Role      string
	InvitedBy string
	Disabled  bool
}

Jump to

Keyboard shortcuts

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