data

package
v0.0.0-...-a57c2c0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateShortID

func GenerateShortID() (string, error)

func MakeIndexes

func MakeIndexes() error

func OpenDBSession

func OpenDBSession(url string) (err error)

Types

type Account

type Account struct {
	ID              bson.ObjectId   `bson:"_id"`
	Emails          []AccountEmail  `bson:"emails"`
	Password        AccountPassword `bson:"password"`
	OrganizationIDs []bson.ObjectId `bson:"organization_ids"`

	CreatedAt  time.Time `bson:"created_at"`
	ModifiedAt time.Time `bson:"modified_at"`
}

func GetAccount

func GetAccount(id bson.ObjectId) (*Account, error)

func GetAccountEmail

func GetAccountEmail(addr string) (*Account, error)

func (*Account) NOrganizations

func (a *Account) NOrganizations() (int, error)

func (*Account) Organizations

func (a *Account) Organizations() ([]Organization, error)

func (*Account) PrimaryEmail

func (a *Account) PrimaryEmail() AccountEmail

func (*Account) Put

func (a *Account) Put() error

type AccountEmail

type AccountEmail struct {
	Address     string `bson:"address"`
	AddressNorm string `bson:"address_norm"`

	Primary bool `bson:"primary"`

	Verified   bool      `bson:"verified"`
	VerifiedAt time.Time `bson:"verified_at"`
	Token      string    `bson:"token"`
}

func NewAccountEmail

func NewAccountEmail(addr string) (AccountEmail, error)

type AccountPassword

type AccountPassword struct {
	Salt       []byte `bson:"salt"`
	Iteration  int    `bson:"iteration"`
	KeyLength  int    `bson:"keyLength"`
	DerivedKey []byte `bson:"derivedKey"`
}

type Document

type Document struct {
	ID          bson.ObjectId `bson:"_id"`
	ProjectID   bson.ObjectId `bson:"project_id"`
	ShortID     string        `bson:"short_id,omitempty"`
	Title       string        `bson:"title"`
	Content     string        `bson:"content"`
	Tags        []string      `bson:"tags"`
	Published   bool          `bson:"publishd"`
	PublishedAt time.Time     `bson:"pushlished_at"`
	Deleted     bool          `bson:"deleted"`
	DeletedAt   time.Time     `bson:"deleted_at"`
	AccessToken string        `bson:"access_token"`
	CreatedAt   time.Time     `bson:"created_at"`
	ModifiedAt  time.Time     `bson:"modified_at"`
}

func GetDocument

func GetDocument(id bson.ObjectId) (*Document, error)

func GetDocumentShortID

func GetDocumentShortID(shortID string) (*Document, error)

func ListDocumentsProject

func ListDocumentsProject(projectID bson.ObjectId, skip, limit int) ([]Document, error)

func (*Document) Project

func (d *Document) Project() (*Project, error)

func (*Document) Put

func (d *Document) Put() error

type Member

type Member struct {
	ID             bson.ObjectId `bson:"_id"`
	ProjectID      bson.ObjectId `bson:"project_id"`
	OrganizationID bson.ObjectId `bson:"organization_id"`
	AccountID      bson.ObjectId `bson:"account_id"`
	InviterID      bson.ObjectId `bson:"inviter_id"`
	InvitedAt      time.Time     `bson:"invited_at"`

	ModifiedAt time.Time `bson:"modified_at"`
	CreatedAt  time.Time `bson:"created_at"`
}

func GetMember

func GetMember(id bson.ObjectId) (*Member, error)

func GetMemberProjectAccount

func GetMemberProjectAccount(pID bson.ObjectId, aID bson.ObjectId) (*Member, error)

func ListMembersAccount

func ListMembersAccount(accID bson.ObjectId, skip, limit int) ([]Member, error)

func ListMembersOrganizationAccount

func ListMembersOrganizationAccount(orgID, accID bson.ObjectId, skip, limit int) ([]Member, error)

func ListMembersProject

func ListMembersProject(projectID bson.ObjectId, skip, limit int) ([]Member, error)

func (*Member) Account

func (m *Member) Account() (*Account, error)

func (*Member) Inviter

func (m *Member) Inviter() (*Account, error)

func (*Member) Organization

func (m *Member) Organization() (*Organization, error)

func (*Member) Project

func (m *Member) Project() (*Project, error)

func (*Member) Put

func (m *Member) Put() error

type Organization

type Organization struct {
	ID         bson.ObjectId `bson:"_id"`
	Name       string        `bson:"name"`
	OwnerID    bson.ObjectId `bson:"owner_id"`
	CreatorID  bson.ObjectId `bson:"creator_id"`
	CreatedAt  time.Time     `bson:"created_at"`
	ModifiedAt time.Time     `bson:"modified_at"`
}

func GetOrganization

func GetOrganization(id bson.ObjectId) (*Organization, error)

func ListOraganizationsOwner

func ListOraganizationsOwner(ownerID bson.ObjectId, skip, limit int) ([]Organization, error)

func (*Organization) Put

func (o *Organization) Put() error

type Project

type Project struct {
	ID             bson.ObjectId   `bson:"_id"`
	Name           string          `bson:"name"`
	OwnerID        bson.ObjectId   `bson:"owner_id"`
	OrganizationID bson.ObjectId   `bson:"organization_id"`
	MemberIDs      []bson.ObjectId `bson:"member_ids"`
	CreatedAt      time.Time       `bson:"created_at"`
	ModifiedAt     time.Time       `bson:"modified_at"`
}

func GetProject

func GetProject(id bson.ObjectId) (*Project, error)

func ListProjectsOrganization

func ListProjectsOrganization(orgID bson.ObjectId, skip, limit int) ([]Project, error)

func (*Project) Members

func (p *Project) Members() ([]Member, error)

func (*Project) Organization

func (p *Project) Organization() (*Organization, error)

func (*Project) Owner

func (p *Project) Owner() (*Account, error)

func (*Project) Put

func (p *Project) Put() error

Jump to

Keyboard shortcuts

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