Documentation
¶
Index ¶
- func GetLatestProductNumber(db *gorm.DB, documentTypeName, productName string) (int, error)
- func ModelsToAutoMigrate() []interface{}
- type Document
- type DocumentCustomField
- 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
// 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"`
// Status is the status of the document.
Status DocumentStatus
// 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.
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 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.