mongodoc

package
v0.0.0-...-6f054a7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 11 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 PermittableDocument

type PermittableDocument struct {
	ID      string
	UserID  string
	RoleIDs []string
}

func (*PermittableDocument) Model

type RoleConsumer

type RoleConsumer = mongox.SliceFuncConsumer[*RoleDocument, *role.Role]

func NewRoleConsumer

func NewRoleConsumer() *RoleConsumer

type RoleDocument

type RoleDocument struct {
	ID   string
	Name string
}

func NewRole

func NewRole(g role.Role) (*RoleDocument, string)

func (*RoleDocument) Model

func (d *RoleDocument) Model() (*role.Role, error)

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