Documentation
¶
Index ¶
- func GetLatestProductNumber(db *gorm.DB, documentTypeName, productName string) (int, error)
- func ModelsToAutoMigrate() []interface{}
- type Document
- func (d *Document) BeforeSave(tx *gorm.DB) error
- func (d *Document) Create(db *gorm.DB) error
- func (d *Document) Delete(db *gorm.DB) error
- func (d *Document) Get(db *gorm.DB) error
- func (d *Document) GetProjects(db *gorm.DB) ([]Project, error)
- func (d *Document) GetRelatedResources(db *gorm.DB) (elrrs []DocumentRelatedResourceExternalLink, ...)
- func (d *Document) ReplaceRelatedResources(db *gorm.DB, elrrs []DocumentRelatedResourceExternalLink, ...) error
- func (d *Document) Upsert(db *gorm.DB) error
- type DocumentCustomField
- type DocumentFileRevision
- type DocumentFileRevisions
- type DocumentGroupReview
- type DocumentGroupReviews
- type DocumentRelatedResource
- type DocumentRelatedResourceExternalLink
- type DocumentRelatedResourceExternalLinks
- type DocumentRelatedResourceHermesDocument
- type DocumentReview
- type DocumentReviewStatus
- type DocumentReviews
- type DocumentStatus
- type DocumentType
- type DocumentTypeCustomField
- type DocumentTypeCustomFieldType
- type DocumentTypes
- type Documents
- type Group
- type IndexerFolder
- type IndexerMetadata
- type Product
- type ProductLatestDocumentNumber
- type Project
- func (p *Project) Create(db *gorm.DB) error
- func (p *Project) Get(db *gorm.DB, id uint) error
- func (p *Project) GetRelatedResources(db *gorm.DB) (elrrs []ProjectRelatedResourceExternalLink, ...)
- func (p *Project) ReplaceRelatedResources(db *gorm.DB, elrrs []ProjectRelatedResourceExternalLink, ...) error
- func (p *Project) Update(db *gorm.DB) error
- type ProjectRelatedResource
- type ProjectRelatedResourceExternalLink
- type ProjectRelatedResourceExternalLinks
- type ProjectRelatedResourceHermesDocument
- type ProjectStatus
- type RecentlyViewedDoc
- type RecentlyViewedProject
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLatestProductNumber ¶
GetLatestProductNumber gets the latest document number for a product.
func ModelsToAutoMigrate ¶
func ModelsToAutoMigrate() []interface{}
Types ¶
type Document ¶
type Document struct {
gorm.Model
// GoogleFileID is the Google Drive file ID of the document.
GoogleFileID string `gorm:"index;not null;unique"`
// Approvers is the list of users whose approval is requested for the
// document.
Approvers []*User `gorm:"many2many:document_reviews;"`
// ApproverGroups is the list of groups whose approval is requested for the
// document.
ApproverGroups []*Group `gorm:"many2many:document_group_reviews;"`
// Contributors are users who have contributed to the document.
Contributors []*User `gorm:"many2many:document_contributors;"`
// CustomFields contains custom fields.
CustomFields []*DocumentCustomField
// DocumentCreatedAt is the time of document creation.
DocumentCreatedAt time.Time
// DocumentModifiedAt is the time the document was last modified.
DocumentModifiedAt time.Time
// DocumentNumber is a document number unique to each product/area. It
// pairs with the product abbreviation to form a document identifier
// (e.g., "TF-123").
DocumentNumber int `gorm:"index:latest_product_number"`
// DocumentType is the document type.
DocumentType DocumentType
DocumentTypeID uint
// DocumentFileRevision are the file revisions for the document.
FileRevisions []DocumentFileRevision
// Imported is true if the document was not created through the application.
Imported bool
// Locked is true if the document cannot be updated (may be in a bad state).
Locked bool
// Owner is the owner of the document.
Owner *User `gorm:"default:null;not null"`
OwnerID *uint `gorm:"default:null"`
// Product is the product or area that the document relates to.
Product Product
ProductID uint `gorm:"index:latest_product_number"`
// RelatedResources are the related resources for the document.
RelatedResources []*DocumentRelatedResource
// Status is the status of the document.
Status DocumentStatus
// status.
ShareableAsDraft bool
// Summary is a summary of the document.
Summary *string
// Title is the title of the document. It only contains the title, and not the
// product abbreviation, document number, or document type.
Title string
}
Document is a model for a document.
func (*Document) BeforeSave ¶
BeforeSave is a hook used to find associations before saving.
func (*Document) Get ¶
Get gets a document from database db by Google file ID, and assigns it to the receiver.
func (*Document) GetProjects ¶ added in v0.4.0
GetProjects gets all projects associated with document d.
func (*Document) GetRelatedResources ¶ added in v0.3.0
func (d *Document) GetRelatedResources(db *gorm.DB) ( elrrs []DocumentRelatedResourceExternalLink, hdrrs []DocumentRelatedResourceHermesDocument, err error, )
GetRelatedResources returns typed related resources for document d.
func (*Document) ReplaceRelatedResources ¶ added in v0.3.0
func (d *Document) ReplaceRelatedResources( db *gorm.DB, elrrs []DocumentRelatedResourceExternalLink, hdrrs []DocumentRelatedResourceHermesDocument, ) error
ReplaceRelatedResources replaces related resources for document d.
type DocumentCustomField ¶
type DocumentCustomField struct {
DocumentID uint `gorm:"primaryKey"`
DocumentTypeCustomFieldID uint `gorm:"primaryKey"`
DocumentTypeCustomField DocumentTypeCustomField
// Value datatypes.JSON
Value string
}
func UpsertStringDocumentCustomField ¶ added in v0.4.0
func UpsertStringDocumentCustomField( documentCustomFields []*DocumentCustomField, documentTypeName string, documentTypeCustomFieldName string, customFieldValue string, ) []*DocumentCustomField
UpsertStringDocumentCustomField upserts a string document custom field with the provided document type name (documentTypeName), document type custom field name (documentTypeCustomFieldName), and value (customFieldValue) into a document's custom fields (documentCustomFields), and returns the resulting custom field (pointer) slice. If the value is an empty string, the custom field will be removed from the result.
func UpsertStringSliceDocumentCustomField ¶ added in v0.4.0
func UpsertStringSliceDocumentCustomField( documentCustomFields []*DocumentCustomField, documentTypeName string, documentTypeCustomFieldName string, customFieldValue []string, ) ([]*DocumentCustomField, error)
UpsertStringSliceDocumentCustomField upserts a string slice document custom field with the provided document type name (documentTypeName), document type custom field name (documentTypeCustomFieldName), and value (customFieldValue) into a document's custom fields (documentCustomFields), and returns the resulting custom field (pointer) slice. If the value is an empty string slice, the custom field will be removed from the result.
func (*DocumentCustomField) BeforeSave ¶
func (d *DocumentCustomField) BeforeSave(tx *gorm.DB) error
BeforeSave is a hook to find or create associations before saving.
type DocumentFileRevision ¶ added in v0.4.0
type DocumentFileRevision struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Document Document
DocumentID uint `gorm:"primaryKey"`
// GoogleDriveFileRevisionID is the ID of the Google Drive file revision.
GoogleDriveFileRevisionID string `gorm:"primaryKey"`
// Name is the name of the document file revision.
Name string `gorm:"primaryKey"`
}
DocumentFileRevision is a model for a document's Google Drive file revisions.
type DocumentFileRevisions ¶ added in v0.4.0
type DocumentFileRevisions []DocumentFileRevision
DocumentFileRevisions is a slice of document file revisions.
type DocumentGroupReview ¶ added in v0.5.0
type DocumentGroupReview struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DocumentID uint `gorm:"primaryKey"`
Document Document
GroupID uint `gorm:"primaryKey"`
Group Group
}
func (*DocumentGroupReview) BeforeSave ¶ added in v0.5.0
func (d *DocumentGroupReview) BeforeSave(tx *gorm.DB) error
BeforeSave is a hook to find or create associations before saving.
type DocumentGroupReviews ¶ added in v0.5.0
type DocumentGroupReviews []DocumentGroupReview
DocumentReviews is a slice of document reviews.
func (*DocumentGroupReviews) Find ¶ added in v0.5.0
func (d *DocumentGroupReviews) Find(db *gorm.DB, dr DocumentGroupReview) error
Find finds all document group reviews with the provided query, and assigns them to the receiver.
type DocumentRelatedResource ¶ added in v0.3.0
type DocumentRelatedResource struct {
gorm.Model
// Document is the document that the related resource is attached to.
Document Document
DocumentID uint `gorm:"uniqueIndex:document_id_sort_order_unique"`
// RelatedResourceID is the foreign key of the related resource, set by a Gorm
// polymorphic relationship.
RelatedResourceID uint `gorm:"default:null;not null"`
// RelatedResourceType is the table for the related resource, set by a Gorm
// polymorphic relationship.
RelatedResourceType string `gorm:"default:null;not null"`
// SortOrder is the relative order of the related resource in comparison to
// all of the document's other related resources.
SortOrder int `gorm:"default:null;not null;uniqueIndex:document_id_sort_order_unique"`
}
DocumentRelatedResource is a model for a document related resource.
type DocumentRelatedResourceExternalLink ¶ added in v0.3.0
type DocumentRelatedResourceExternalLink struct {
gorm.Model
RelatedResource DocumentRelatedResource `gorm:"polymorphic:RelatedResource"`
Name string `gorm:"default:null;not null"`
URL string `gorm:"default:null;not null"`
}
type DocumentRelatedResourceExternalLinks ¶ added in v0.3.0
type DocumentRelatedResourceExternalLinks []DocumentRelatedResourceExternalLink
type DocumentRelatedResourceHermesDocument ¶ added in v0.3.0
type DocumentRelatedResourceHermesDocument struct {
gorm.Model
RelatedResource DocumentRelatedResource `gorm:"polymorphic:RelatedResource"`
// Document is the target related document.
Document Document
DocumentID uint
}
type DocumentReview ¶
type DocumentReview struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DocumentID uint `gorm:"primaryKey"`
Document Document
UserID uint `gorm:"primaryKey"`
User User
Status DocumentReviewStatus
}
func (*DocumentReview) BeforeSave ¶
func (d *DocumentReview) BeforeSave(tx *gorm.DB) error
BeforeSave is a hook to find or create associations before saving.
type DocumentReviewStatus ¶
type DocumentReviewStatus int
const ( UnspecifiedDocumentReviewStatus DocumentReviewStatus = iota ApprovedDocumentReviewStatus ChangesRequestedDocumentReviewStatus )
type DocumentReviews ¶
type DocumentReviews []DocumentReview
DocumentReviews is a slice of document reviews.
func (*DocumentReviews) Find ¶
func (d *DocumentReviews) Find(db *gorm.DB, dr DocumentReview) error
Find finds all document reviews with the provided query, and assigns them to the receiver.
type DocumentStatus ¶
type DocumentStatus int
DocumentStatus is the status of the document (e.g., "WIP", "In-Review", "Approved", "Obsolete").
const ( UnspecifiedDocumentStatus DocumentStatus = iota WIPDocumentStatus InReviewDocumentStatus ApprovedDocumentStatus ObsoleteDocumentStatus )
type DocumentType ¶
type DocumentType struct {
gorm.Model
// Name is the name of the document type, generally an abbreviation.
// Example: "RFC"
Name string `gorm:"index;not null;unique"`
// LongName is the longer name for the document type.
// Example: "Request for Comments"
LongName string `gorm:"default:null;not null"`
// Description is the description of the document type.
// Example: "Create a Request for Comments document to present a proposal to
// colleagues for their review and feedback."
Description string
// FlightIcon is the name of the Helios flight icon.
// From: https://helios.hashicorp.design/icons/library
FlightIcon string
// MoreInfoLinkText is the text for a "more info" link.
// Example: "When should I create an RFC?"
MoreInfoLinkText string
// MoreInfoLinkURL is the URL for a "more info" link.
MoreInfoLinkURL string
// CustomFields contain custom fields that are specific to a particular
// document type.
CustomFields []DocumentTypeCustomField
// Checks are document type checks, which require acknowledging a check box in
// order to publish a document.
Checks datatypes.JSON
}
DocumentType is a model for a type of document (e.g., "RFC", "PRD").
func (*DocumentType) FirstOrCreate ¶
func (d *DocumentType) FirstOrCreate(db *gorm.DB) error
FirstOrCreate finds the first document type by name or creates a new record if it does not exist.
type DocumentTypeCustomField ¶
type DocumentTypeCustomField struct {
gorm.Model
Name string
DocumentTypeID uint
DocumentType DocumentType
ReadOnly bool
Type DocumentTypeCustomFieldType
}
type DocumentTypeCustomFieldType ¶
type DocumentTypeCustomFieldType int
const ( UnspecifiedDocumentTypeCustomFieldType DocumentTypeCustomFieldType = iota StringDocumentTypeCustomFieldType PersonDocumentTypeCustomFieldType PeopleDocumentTypeCustomFieldType )
type Group ¶ added in v0.5.0
type Group struct {
gorm.Model
// EmailAddress is the email address of the group.
EmailAddress string `gorm:"default:null;index;not null;type:citext;unique"`
}
Group is a model for an application group.
func (*Group) FirstOrCreate ¶ added in v0.5.0
FirstOrCreate finds the first group by email address or creates a group record if it does not exist in database db. The result is saved back to the receiver.
type IndexerFolder ¶
type IndexerFolder struct {
gorm.Model
// GoogleDriveID is the Google Drive ID of the folder.
GoogleDriveID string `gorm:"default:null;not null;uniqueIndex"`
// LastIndexedAt is the time that the folder was last indexed.
LastIndexedAt time.Time
}
IndexerFolder is a model for a indexer folder.
type IndexerMetadata ¶
type IndexerMetadata struct {
gorm.Model
// LastFullIndexAt is the time that the indexer last completed a full index.
LastFullIndexAt time.Time
}
Indexer is a model for indexer metadata.
type Product ¶
type Product struct {
gorm.Model
// Name is the name of the product.
Name string `gorm:"default:null;index;not null;type:citext;unique"`
// Abbreviation is a short group of capitalized letters to represent the
// product.
Abbreviation string `gorm:"default:null;not null;type:citext;unique"`
// UserSubscribers are the users that subscribed to this product.
UserSubscribers []User `gorm:"many2many:user_product_subscriptions;"`
}
Product is a model for product data.
func (*Product) FirstOrCreate ¶
FirstOrCreate finds the first product by name or creates a record if it does not exist in database db.
type ProductLatestDocumentNumber ¶
type ProductLatestDocumentNumber struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DocumentType DocumentType
DocumentTypeID uint `gorm:"primaryKey"`
Product Product
ProductID uint `gorm:"primaryKey"`
// LatestDocumentNumber is a the latest document number per product and
// document type.
LatestDocumentNumber int `gorm:"default:null;not null"`
}
ProductLatestDocumentNumber is a model for latest product document numbers.
func (*ProductLatestDocumentNumber) BeforeSave ¶
func (p *ProductLatestDocumentNumber) BeforeSave(tx *gorm.DB) error
BeforeSave is a hook to find or create associations before saving.
type Project ¶ added in v0.4.0
type Project struct {
gorm.Model
// Creator is the user that created the project.
Creator User
CreatorID uint `gorm:"default:null;not null"`
// Description is a description of the project.
Description *string
// JiraIssueID is the ID of the Jira issue associated with the project.
JiraIssueID *string
// ProjectCreatedAt is the time of project creation.
ProjectCreatedAt time.Time `gorm:"default:null;not null"`
// ProjectModifiedAt is the time the project was last modified.
ProjectModifiedAt time.Time `gorm:"default:null;not null"`
// RelatedResources are the related resources for the project.
RelatedResources []*ProjectRelatedResource
// Status is the status of the document.
Status ProjectStatus `gorm:"default:null;not null"`
// Title is the title of the project.
Title string `gorm:"default:null;not null"`
}
Project is a model for a project.
func (*Project) Create ¶ added in v0.4.0
Create creates a new project. The resulting project is saved back to the receiver.
func (*Project) GetRelatedResources ¶ added in v0.4.0
func (p *Project) GetRelatedResources(db *gorm.DB) ( elrrs []ProjectRelatedResourceExternalLink, hdrrs []ProjectRelatedResourceHermesDocument, err error, )
GetRelatedResources returns typed related resources for project p.
func (*Project) ReplaceRelatedResources ¶ added in v0.4.0
func (p *Project) ReplaceRelatedResources( db *gorm.DB, elrrs []ProjectRelatedResourceExternalLink, hdrrs []ProjectRelatedResourceHermesDocument, ) error
ReplaceRelatedResources replaces related resources for project p.
type ProjectRelatedResource ¶ added in v0.4.0
type ProjectRelatedResource struct {
gorm.Model
// Project is the project that the related resource is attached to.
Project Project
ProjectID uint `gorm:"uniqueIndex:project_id_sort_order_unique"`
// RelatedResourceID is the foreign key of the related resource, set by a Gorm
// polymorphic relationship.
RelatedResourceID uint `gorm:"default:null;not null"`
// RelatedResourceType is the table for the related resource, set by a Gorm
// polymorphic relationship.
RelatedResourceType string `gorm:"default:null;not null"`
// SortOrder is the relative order of the related resource in comparison to
// all of the project's other related resources.
SortOrder int `gorm:"default:null;not null;uniqueIndex:project_id_sort_order_unique"`
}
ProjectRelatedResource is a model for a project related resource.
type ProjectRelatedResourceExternalLink ¶ added in v0.4.0
type ProjectRelatedResourceExternalLink struct {
gorm.Model
RelatedResource ProjectRelatedResource `gorm:"polymorphic:RelatedResource"`
Name string `gorm:"default:null;not null"`
URL string `gorm:"default:null;not null"`
}
type ProjectRelatedResourceExternalLinks ¶ added in v0.4.0
type ProjectRelatedResourceExternalLinks []ProjectRelatedResourceExternalLink
type ProjectRelatedResourceHermesDocument ¶ added in v0.4.0
type ProjectRelatedResourceHermesDocument struct {
gorm.Model
RelatedResource ProjectRelatedResource `gorm:"polymorphic:RelatedResource"`
// Document is the target related Hermes document.
Document Document
DocumentID uint
}
type ProjectStatus ¶ added in v0.4.0
type ProjectStatus int
ProjectStatus is the status of the project.
const ( UnspecifiedProjectStatus ProjectStatus = iota ActiveProjectStatus CompletedProjectStatus ArchivedProjectStatus )
func ParseProjectStatusString ¶ added in v0.4.0
func ParseProjectStatusString(s string) (ProjectStatus, bool)
func (ProjectStatus) String ¶ added in v0.4.0
func (s ProjectStatus) String() string
type RecentlyViewedDoc ¶
type RecentlyViewedProject ¶ added in v0.5.0
type User ¶
type User struct {
gorm.Model
// EmailAddress is the email address of the user.
EmailAddress string `gorm:"default:null;index;not null;type:citext;unique"`
// ProductSubscriptions are the products that have been subscribed to by the
// user.
ProductSubscriptions []Product `gorm:"many2many:user_product_subscriptions;"`
// RecentlyViewedDocs are the documents recently viewed by the user.
RecentlyViewedDocs []Document `gorm:"many2many:recently_viewed_docs;"`
// RecentlyViewedProjects are the projects recently viewed by the user.
RecentlyViewedProjects []Project `gorm:"many2many:recently_viewed_projects;"`
}
User is a model for an application user.
func (*User) BeforeSave ¶
BeforeSave is a hook to find or create associations before saving.
func (*User) FirstOrCreate ¶
FirstOrCreate finds the first user by email address or creates a user record if it does not exist in database db. The result is saved back to the receiver.
Source Files
¶
- document.go
- document_custom_field.go
- document_file_revision.go
- document_group_review.go
- document_related_resource.go
- document_related_resource_external_link.go
- document_related_resource_hermes_document.go
- document_review.go
- document_type.go
- document_type_custom_field.go
- gorm.go
- group.go
- indexer_folder.go
- indexer_metadata.go
- product.go
- product_latest_document_number.go
- project.go
- project_related_resource.go
- project_related_resource_external_link.go
- project_related_resource_hermes_document.go
- testing.go
- user.go