mongodoc

package
v0.0.0-...-b80d6b0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 14 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)

Types

type Auth

type Auth struct {
	Cert string
	Key  string
}

func NewConfigAuth

func NewConfigAuth(c *config.Auth) *Auth

type ConfigDocument

type ConfigDocument struct {
	Migration     int64
	Auth          *Auth
	DefaultPolicy *policy.ID
}

func NewConfig

func NewConfig(c config.Config) ConfigDocument

func (*ConfigDocument) Model

func (c *ConfigDocument) Model() *config.Config

type Consumer

type Consumer[T, K any] struct {
	Result []K
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer[T Model[U], U any](filter func(U) bool) *Consumer[T, U]

func (*Consumer[T, K]) Consume

func (s *Consumer[T, K]) Consume(raw bson.Raw) error

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 PermittableConsumer

type PermittableConsumer = Consumer[*PermittableDocument, *permittable.Permittable]

func NewPermittableConsumer

func NewPermittableConsumer() *PermittableConsumer

type PermittableDocument

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

func (*PermittableDocument) Model

type RoleConsumer

type RoleConsumer = Consumer[*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
	Alias         string
	Email         string
	Subs          []string
	Workspace     string
	Team          string `bson:",omitempty"`
	Lang          string
	Theme         string
	Password      []byte
	PasswordReset *PasswordResetDocument
	Verification  *UserVerificationDoc
	Metadata      UserMetadataDoc
}

func NewUser

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

func (*UserDocument) Model

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

type UserMetadataDoc

type UserMetadataDoc struct {
	Description string
	Website     string
	PhotoURL    string
	Lang        string
	Theme       string
}

type UserVerificationDoc

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

type WorkspaceConsumer

type WorkspaceConsumer = Consumer[*WorkspaceDocument, *workspace.Workspace]

func NewWorkspaceConsumer

func NewWorkspaceConsumer() *WorkspaceConsumer

type WorkspaceDocument

type WorkspaceDocument struct {
	ID           string
	Name         string
	Alias        string
	Email        string
	Metadata     WorkspaceMetadataDocument
	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
}

type WorkspaceMetadataDocument

type WorkspaceMetadataDocument struct {
	Description  string
	Website      string
	Location     string
	BillingEmail string
	PhotoURL     string
}

Jump to

Keyboard shortcuts

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