Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllModels ¶
func GetAllModels() []interface{}
GetAllModels returns all GORM models, that is, a slice of pointers to zero-valued structs.
Types ¶
type Feed ¶
type Feed struct { Model DeletedAt gorm.DeletedAt `gorm:"index"` // URL is the unique URL of the feed. URL string `gorm:"not null;uniqueIndex"` // LastRetrievedAt is the date and time when this feed was last visited // to successfully retrieve and process its content. LastRetrievedAt sql.NullTime `gorm:"index"` FailuresCount int `gorm:"not null"` // FeedItems is the has-many relation with FeedItem models. FeedItems []FeedItem `gorm:"constraint:OnDelete:CASCADE"` }
Feed is a model representing an RSS or Atom feed.
type FeedItem ¶
type FeedItem struct { Model // FeedID is the association to the Feed this item belongs to. FeedID uint `gorm:"not null"` // WebResourceID allows the has-one relation with a WebResource. WebResourceID uint `gorm:"not null;uniqueIndex;constraint:OnDelete:CASCADE"` Title string Description sql.NullString Content sql.NullString Language string `gorm:"not null"` PublishedAt sql.NullTime }
FeedItem extends a WebResource which is the item of a Feed.
type GDELTEvent ¶
type GDELTEvent struct { Model // WebResourceID allows the has-one relation with a WebResource. WebResourceID uint `gorm:"not null;uniqueIndex;constraint:OnDelete:CASCADE"` // GlobalEventID is the globally unique identifier in GDELT master dataset. GlobalEventID uint `gorm:"not null;uniqueIndex"` // DateAdded is the date the event was added to the master database. DateAdded time.Time `gorm:"not null"` // LocationType specifies the geographic resolution of the match type. LocationType sql.NullString // LocationName is the full human-readable name of the matched location. LocationName sql.NullString // CountryCode is the ISO 3166-1 alpha2 country code for the location. CountryCode sql.NullString // Coordinates provides the centroid Longitude (X) and Latitude (Y) of the landmark for mapping. Coordinates pgtype.Point `gorm:"type:point"` // EventCategories provides one or more CAMEO event codes at different // levels. EventCategories pgtype.VarcharArray `gorm:"type:varchar(4)[];not null"` }
GDELTEvent represents a GDELT Event, and it extends a WebResource which contains the URL of the first recognized news report for this event.
type Model ¶
type Model struct { ID uint `gorm:"primaryKey"` CreatedAt time.Time `gorm:"not null"` UpdatedAt time.Time `gorm:"not null"` }
Model is the basic struct embedded into all GORM models.
type Payload ¶
type Payload map[string]interface{}
Payload is a generic payload for a WebArticle.
func (*Payload) Get ¶
Get gets a value from the given key. If multiple keys are given, the method attempts to match a series of nested maps. If a value is not found, or the search in nested maps fails, the returned value is nil, and the flag is false.
func (*Payload) GetString ¶
GetString gets the value with Get and enforces it to be a string. If no value is found, or the value is not a string, the method returns an empty string and a false flag.
type WebArticle ¶
type WebArticle struct { Model // WebResourceID allows the has-one relation with a WebResource. WebResourceID uint `gorm:"not null;uniqueIndex;constraint:OnDelete:CASCADE"` Title string `gorm:"not null;index"` TitleUnmodified string CleanedText string CanonicalLink string TopImage string FinalURL string ScrapedPublishDate sql.NullTime Language string `gorm:"not null"` PublishDate time.Time `gorm:"not null"` RelatedToWebArticleID *uint RelatedToWebArticle *WebArticle RelatedScore sql.NullFloat64 Payload Payload `gorm:"type:JSONB"` Vector pgtype.Bytea `gorm:"type:bytea"` }
WebArticle represents the scraped content of a WebResource.
func FindWebArticle ¶
func FindWebArticle(tx *gorm.DB, id uint) (*WebArticle, error)
FindWebArticle returns the web article by its id. It returns nil if the item is not found.
type WebResource ¶
type WebResource struct { Model // URL is the unique URL of the web resource. URL string `gorm:"not null;uniqueIndex"` // WebArticle represents the scraped content of this WebResource. WebArticle WebArticle // FeedItem allows the has-one relation with a models.FeedItem. FeedItem FeedItem // GDELTEvent allows the has-one relation with a models.GDELTEvent. GDELTEvent GDELTEvent }
WebResource represents a web resource, usually a web page, accessible via a URL.
func FindWebResourceByURL ¶
func FindWebResourceByURL(tx *gorm.DB, url string) (*WebResource, error)
FindWebResourceByURL returns the web resource associated to a url. It returns nil if the item is not found.