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) Get(db *gorm.DB) 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 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 IndexerFolder
- type IndexerMetadata
- type Product
- type ProductLatestDocumentNumber
- type RecentlyViewedDoc
- 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;"` // 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 // 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) 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 { CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` DocumentID uint `gorm:"primaryKey"` DocumentTypeCustomFieldID uint `gorm:"primaryKey"` DocumentTypeCustomField DocumentTypeCustomField // Value datatypes.JSON Value string }
func (*DocumentCustomField) BeforeSave ¶
func (d *DocumentCustomField) BeforeSave(tx *gorm.DB) error
BeforeSave is a hook to find or create associations before saving.
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 // 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 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 RecentlyViewedDoc ¶
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;"` }
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_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
- indexer_folder.go
- indexer_metadata.go
- product.go
- product_latest_document_number.go
- testing.go
- user.go