Documentation
¶
Overview ¶
Package items allows for interactions with items in the Library of Congress digital collections.
It provides a Repository interface for generalized interactions storing and retrieving items from a data store, as well as a concrete type that implements that interface for a PostgreSQL database using the pgx package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
ID string
URL sql.NullString
Title sql.NullString
Year sql.NullInt32
Date sql.NullString
Subjects []string
Resources []ItemResource
Files []ItemFile
Languages []string
API sql.NullString // The entire API response stored as JSONB
Updated time.Time
}
Item is a representation of an item in the LOC digital collections, along with its resources and files.
type ItemFile ¶
type ItemFile struct {
ItemID string
ResourceSeq int
FileSeq int
FormatSeq int
Mimetype sql.NullString
FullText sql.NullString
FullTextService sql.NullString
WordCoordinates sql.NullString
URL sql.NullString
Info sql.NullString
Use sql.NullString
}
ItemFile is a file contained within an item. Unlike the LOC.gov API, this model does not make a firm distinction between a file and format.
type ItemResource ¶
type ItemResource struct {
ItemID string
ResourceSeq int
FullTextFile sql.NullString
DJVUTextFile sql.NullString
Image sql.NullString
PDF sql.NullString
URL sql.NullString
Caption sql.NullString
}
ItemResource is a resource attached to an item.
type ItemResponse ¶
type ItemResponse struct {
ItemDetails struct {
ID string `json:"id"`
URL string `json:"url"`
Date string `json:"date"`
Subjects []string `json:"subject_headings"`
Title string `json:"title"`
Language []string `json:"language"`
} `json:"item"`
Resources []struct {
FulltextFile string `json:"fulltext_file,omitempty"`
DJVUTextFile string `json:"djvu_text_file,omitempty"`
Image string `json:"image,omitempty"`
PDF string `json:"pdf,omitempty"`
URL string `json:"url,omitempty"`
Caption string `json:"caption,omitempty"`
Files [][]struct {
Mimetype string `json:"mimetype,omitempty"`
Fulltext string `json:"fulltext,omitempty"`
FulltextService string `json:"fulltext_service,omitempty"`
WordCoordinates string `json:"word_coordinates,omitempty"`
URL string `json:"url,omitempty"`
Info string `json:"info,omitempty"`
Use string `json:"use,omitempty"`
} `json:"files"`
} `json:"resources"`
}
ItemResponse represents an item-level object returned from the API. Many more fields are returned and will be stored in the database as a JSONB field, but these are the ones that will be serialized to regular database fields.
type PlainText ¶
type PlainText struct {
Text string
}
PlainText is the cleaned up, plain text of part (or all) of an item.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is a data store using PostgreSQL with the pgx native interface.
func NewItemRepo ¶
NewItemRepo returns an item repo using PostgreSQL with the pgx native interface.
func (*Repo) GetAllUnfetched ¶
GetAllUnfetched gets the IDs of all items which still need to be fetched