Documentation
¶
Index ¶
- Constants
- Variables
- func NewHandle() string
- type Address
- type Attribute
- type ChildRef
- type Citation
- type Database
- func (d *Database) AddCitation(c *Citation) error
- func (d *Database) AddEvent(e *Event) error
- func (d *Database) AddFamily(f *Family) error
- func (d *Database) AddMedia(m *Media) error
- func (d *Database) AddNote(n *Note) error
- func (d *Database) AddPerson(p *Person) error
- func (d *Database) AddPlace(p *Place) error
- func (d *Database) AddRepository(r *Repository) error
- func (d *Database) AddSource(s *Source) error
- func (d *Database) AddTag(t *Tag) error
- func (d *Database) Citations() iter.Seq2[*Citation, error]
- func (d *Database) Close() error
- func (d *Database) DeleteCitation(handle string) error
- func (d *Database) DeleteEvent(handle string) error
- func (d *Database) DeleteFamily(handle string) error
- func (d *Database) DeleteMedia(handle string) error
- func (d *Database) DeleteNote(handle string) error
- func (d *Database) DeletePerson(handle string) error
- func (d *Database) DeletePlace(handle string) error
- func (d *Database) DeleteRepository(handle string) error
- func (d *Database) DeleteSource(handle string) error
- func (d *Database) DeleteTag(handle string) error
- func (d *Database) Dir() string
- func (d *Database) Events() iter.Seq2[*Event, error]
- func (d *Database) Families() iter.Seq2[*Family, error]
- func (d *Database) GetCitation(handle string) (*Citation, error)
- func (d *Database) GetCitationByGrampsID(id string) (*Citation, error)
- func (d *Database) GetEvent(handle string) (*Event, error)
- func (d *Database) GetEventByGrampsID(id string) (*Event, error)
- func (d *Database) GetFamily(handle string) (*Family, error)
- func (d *Database) GetFamilyByGrampsID(id string) (*Family, error)
- func (d *Database) GetMedia(handle string) (*Media, error)
- func (d *Database) GetMediaByGrampsID(id string) (*Media, error)
- func (d *Database) GetMetadata(key string) (any, error)
- func (d *Database) GetNote(handle string) (*Note, error)
- func (d *Database) GetNoteByGrampsID(id string) (*Note, error)
- func (d *Database) GetPerson(handle string) (*Person, error)
- func (d *Database) GetPersonByGrampsID(id string) (*Person, error)
- func (d *Database) GetPlace(handle string) (*Place, error)
- func (d *Database) GetPlaceByGrampsID(id string) (*Place, error)
- func (d *Database) GetRepository(handle string) (*Repository, error)
- func (d *Database) GetRepositoryByGrampsID(id string) (*Repository, error)
- func (d *Database) GetSource(handle string) (*Source, error)
- func (d *Database) GetSourceByGrampsID(id string) (*Source, error)
- func (d *Database) GetTag(handle string) (*Tag, error)
- func (d *Database) GetTagByName(name string) (*Tag, error)
- func (d *Database) MediaObjects() iter.Seq2[*Media, error]
- func (d *Database) Notes() iter.Seq2[*Note, error]
- func (d *Database) People() iter.Seq2[*Person, error]
- func (d *Database) Places() iter.Seq2[*Place, error]
- func (d *Database) Repositories() iter.Seq2[*Repository, error]
- func (d *Database) SchemaVersion() int
- func (d *Database) SetMetadata(key string, value any) error
- func (d *Database) Sources() iter.Seq2[*Source, error]
- func (d *Database) Tags() iter.Seq2[*Tag, error]
- func (d *Database) UpdateCitation(c *Citation) error
- func (d *Database) UpdateEvent(e *Event) error
- func (d *Database) UpdateFamily(f *Family) error
- func (d *Database) UpdateMedia(m *Media) error
- func (d *Database) UpdateNote(n *Note) error
- func (d *Database) UpdatePerson(p *Person) error
- func (d *Database) UpdatePlace(p *Place) error
- func (d *Database) UpdateRepository(r *Repository) error
- func (d *Database) UpdateSource(s *Source) error
- func (d *Database) UpdateTag(t *Tag) error
- type Date
- type ErrLocked
- type ErrUnsupportedSchema
- type Event
- type EventRef
- type Family
- type FamilySearchSync
- type GrampsType
- type LdsOrd
- type Location
- type Media
- type MediaRef
- type Name
- type Note
- type Person
- type PersonRef
- type Place
- type PlaceName
- type PlaceRef
- type RepoRef
- type Repository
- type Source
- type SrcAttribute
- type StyledText
- type StyledTextTag
- type Surname
- type Tag
- type URL
Constants ¶
const ( NoteFlowed = 0 NoteFormatted = 1 )
Note format constants.
const ( GenderFemale = 0 GenderMale = 1 GenderUnknown = 2 GenderOther = 3 )
Gender constants matching Gramps.
Variables ¶
var ErrReadOnly = errors.New("database is read-only")
ErrReadOnly is returned when a write operation is attempted on a read-only database.
Functions ¶
Types ¶
type Address ¶
type Address struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Date *Date `json:"date"`
Street string `json:"street"`
Locality string `json:"locality"`
City string `json:"city"`
County string `json:"county"`
State string `json:"state"`
Country string `json:"country"`
Postal string `json:"postal"`
Phone string `json:"phone"`
}
Address represents a physical address.
type Attribute ¶
type Attribute struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Type GrampsType `json:"type"`
Value string `json:"value"`
}
Attribute represents a person/family/event attribute.
type ChildRef ¶
type ChildRef struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Ref string `json:"ref"`
Frel GrampsType `json:"frel"`
Mrel GrampsType `json:"mrel"`
}
ChildRef is a reference from a Family to a child Person.
type Citation ¶
type Citation struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Date *Date `json:"date"`
Page string `json:"page"`
Confidence int `json:"confidence"`
SourceHandle *string `json:"source_handle"`
NoteList []string `json:"note_list"`
MediaList []MediaRef `json:"media_list"`
AttributeList []SrcAttribute `json:"attribute_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Citation represents a citation of a source in the Gramps database.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents an open Gramps database.
func OpenReadOnly ¶
OpenReadOnly opens an existing Gramps database directory without locking.
func (*Database) AddCitation ¶
func (*Database) AddRepository ¶
func (d *Database) AddRepository(r *Repository) error
func (*Database) DeleteCitation ¶
func (*Database) DeleteEvent ¶
func (*Database) DeleteFamily ¶
func (*Database) DeleteMedia ¶
func (*Database) DeleteNote ¶
func (*Database) DeletePerson ¶
func (*Database) DeletePlace ¶
func (*Database) DeleteRepository ¶
func (*Database) DeleteSource ¶
func (*Database) GetCitationByGrampsID ¶
func (*Database) GetEventByGrampsID ¶
func (*Database) GetFamilyByGrampsID ¶
func (*Database) GetMediaByGrampsID ¶
func (*Database) GetMetadata ¶
GetMetadata retrieves a metadata value by key.
func (*Database) GetPersonByGrampsID ¶
func (*Database) GetPlaceByGrampsID ¶
func (*Database) GetRepository ¶
func (d *Database) GetRepository(handle string) (*Repository, error)
func (*Database) GetRepositoryByGrampsID ¶
func (d *Database) GetRepositoryByGrampsID(id string) (*Repository, error)
func (*Database) GetSourceByGrampsID ¶
func (*Database) Repositories ¶
func (d *Database) Repositories() iter.Seq2[*Repository, error]
func (*Database) SchemaVersion ¶
SchemaVersion returns the schema version number of the database.
func (*Database) SetMetadata ¶
SetMetadata sets a metadata value.
func (*Database) UpdateCitation ¶
func (*Database) UpdateEvent ¶
func (*Database) UpdateFamily ¶
func (*Database) UpdateMedia ¶
func (*Database) UpdateNote ¶
func (*Database) UpdatePerson ¶
func (*Database) UpdatePlace ¶
func (*Database) UpdateRepository ¶
func (d *Database) UpdateRepository(r *Repository) error
func (*Database) UpdateSource ¶
type Date ¶
type Date struct {
Class string `json:"_class"`
Calendar int `json:"calendar"`
Modifier int `json:"modifier"`
Quality int `json:"quality"`
Dateval []int `json:"dateval"`
Text string `json:"text"`
Sortval int `json:"sortval"`
Newyear int `json:"newyear"`
Format *int `json:"format"` // typically nil
}
Date represents a Gramps date object. dateval is stored as an array of integers representing day/month/year values. For simple dates: [day, month, year, slash_flag] For compound dates (range/span): [day1, month1, year1, slash1, day2, month2, year2, slash2]
func (*Date) UnmarshalJSON ¶
UnmarshalJSON implements custom JSON unmarshalling for Date. Gramps Python serializes dateval as e.g. [29, 8, 1987, false] where the 4th (and 8th for compound dates) element is a Python bool (JSON true/false). This method converts booleans to int (false→0, true→1) so that Dateval can remain []int.
type ErrLocked ¶
type ErrLocked struct {
Holder string
}
ErrLocked is returned when the database is already locked by another process.
type ErrUnsupportedSchema ¶
type ErrUnsupportedSchema struct {
Version int
}
ErrUnsupportedSchema is returned when opening a database with an unsupported schema version.
func (*ErrUnsupportedSchema) Error ¶
func (e *ErrUnsupportedSchema) Error() string
type Event ¶
type Event struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Type GrampsType `json:"type"`
Date *Date `json:"date"`
Description string `json:"description"`
Place string `json:"place"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
MediaList []MediaRef `json:"media_list"`
AttributeList []Attribute `json:"attribute_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Event represents an event in the Gramps database.
type EventRef ¶
type EventRef struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
AttributeList []Attribute `json:"attribute_list"`
Ref string `json:"ref"`
Role GrampsType `json:"role"`
}
EventRef is a reference from a Person or Family to an Event.
type Family ¶
type Family struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
FatherHandle *string `json:"father_handle"`
MotherHandle *string `json:"mother_handle"`
ChildRefList []ChildRef `json:"child_ref_list"`
Type GrampsType `json:"type"`
EventRefList []EventRef `json:"event_ref_list"`
MediaList []MediaRef `json:"media_list"`
AttributeList []Attribute `json:"attribute_list"`
LdsOrdList []LdsOrd `json:"lds_ord_list"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
Complete int `json:"complete"`
}
Family represents a family unit in the Gramps database.
type FamilySearchSync ¶
type FamilySearchSync struct {
Class string `json:"_class"`
FSID *string `json:"fsid"`
IsRoot bool `json:"is_root"`
StatusTS *int64 `json:"status_ts"`
ConfirmedTS *int64 `json:"confirmed_ts"`
GrampsModifiedTS *int64 `json:"gramps_modified_ts"`
FSModifiedTS *int64 `json:"fs_modified_ts"`
EssentialConflict bool `json:"essential_conflict"`
Conflict bool `json:"conflict"`
}
FamilySearchSync holds FamilySearch synchronisation state for a person. Added in schema version 22. Absent (nil) in schema 21 databases.
type GrampsType ¶
type GrampsType struct {
Class string `json:"_class"`
Value int `json:"value"`
String string `json:"string"`
}
GrampsType represents a Gramps enumerated type (e.g., EventType, NameType). In JSON it serializes as {"_class": "EventType", "value": 12, "string": ""}. The value is the integer type code, and string is only non-empty for custom types.
type LdsOrd ¶
type LdsOrd struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Date *Date `json:"date"`
Type int `json:"type"`
Place string `json:"place"`
Famc string `json:"famc"`
Temple string `json:"temple"`
Status int `json:"status"`
}
LdsOrd represents an LDS ordinance.
type Location ¶
type Location struct {
Class string `json:"_class"`
Street string `json:"street"`
Locality string `json:"locality"`
City string `json:"city"`
County string `json:"county"`
State string `json:"state"`
Country string `json:"country"`
Postal string `json:"postal"`
Phone string `json:"phone"`
Parish string `json:"parish"`
}
Location represents an alternate location for a place.
type Media ¶
type Media struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Path string `json:"path"`
Mime string `json:"mime"`
Desc string `json:"desc"`
Checksum string `json:"checksum"`
Thumb *string `json:"thumb"`
Date *Date `json:"date"`
AttributeList []Attribute `json:"attribute_list"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Media represents a media object in the Gramps database.
type MediaRef ¶
type MediaRef struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
AttributeList []Attribute `json:"attribute_list"`
Ref string `json:"ref"`
Rect []int `json:"rect"`
}
MediaRef is a reference to a Media object, optionally cropped.
type Name ¶
type Name struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Date *Date `json:"date"`
FirstName string `json:"first_name"`
SurnameList []Surname `json:"surname_list"`
Suffix string `json:"suffix"`
Title string `json:"title"`
Type GrampsType `json:"type"`
GroupAs string `json:"group_as"`
SortAs int `json:"sort_as"`
DisplayAs int `json:"display_as"`
Call string `json:"call"`
Nick string `json:"nick"`
Famnick string `json:"famnick"`
}
Name represents a person's name.
type Note ¶
type Note struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Text StyledText `json:"text"`
Format int `json:"format"`
Type GrampsType `json:"type"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Note represents a note in the Gramps database.
type Person ¶
type Person struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Gender int `json:"gender"`
PrimaryName Name `json:"primary_name"`
AlternateNames []Name `json:"alternate_names"`
DeathRefIndex int `json:"death_ref_index"`
BirthRefIndex int `json:"birth_ref_index"`
EventRefList []EventRef `json:"event_ref_list"`
FamilyList []string `json:"family_list"`
ParentFamilyList []string `json:"parent_family_list"`
MediaList []MediaRef `json:"media_list"`
AddressList []Address `json:"address_list"`
AttributeList []Attribute `json:"attribute_list"`
URLs []URL `json:"urls"`
LdsOrdList []LdsOrd `json:"lds_ord_list"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
PersonRefList []PersonRef `json:"person_ref_list"`
FamilySearchSync *FamilySearchSync `json:"familysearch_sync,omitempty"`
}
Person represents a person in the Gramps database.
type PersonRef ¶
type PersonRef struct {
Class string `json:"_class"`
Private bool `json:"private"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Ref string `json:"ref"`
Rel string `json:"rel"`
}
PersonRef is a reference from one Person to another.
type Place ¶
type Place struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Title string `json:"title"`
Long string `json:"long"`
Lat string `json:"lat"`
PlaceRefList []PlaceRef `json:"placeref_list"`
Name PlaceName `json:"name"`
AltNames []PlaceName `json:"alt_names"`
PlaceType GrampsType `json:"place_type"`
Code string `json:"code"`
AltLoc []Location `json:"alt_loc"`
URLs []URL `json:"urls"`
MediaList []MediaRef `json:"media_list"`
CitationList []string `json:"citation_list"`
NoteList []string `json:"note_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Place represents a place in the Gramps database.
type PlaceName ¶
type PlaceName struct {
Class string `json:"_class"`
Value string `json:"value"`
Date *Date `json:"date"`
Lang string `json:"lang"`
}
PlaceName represents a name of a place, possibly with a date range.
type PlaceRef ¶
type PlaceRef struct {
Class string `json:"_class"`
Ref string `json:"ref"`
Date *Date `json:"date"`
}
PlaceRef is a reference from one Place to another (hierarchy).
type RepoRef ¶
type RepoRef struct {
Class string `json:"_class"`
Private bool `json:"private"`
NoteList []string `json:"note_list"`
Ref string `json:"ref"`
CallNumber string `json:"call_number"`
MediaType GrampsType `json:"media_type"`
}
RepoRef is a reference from a Source to a Repository.
type Repository ¶
type Repository struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Type GrampsType `json:"type"`
Name string `json:"name"`
NoteList []string `json:"note_list"`
AddressList []Address `json:"address_list"`
URLs []URL `json:"urls"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Repository represents a repository in the Gramps database.
type Source ¶
type Source struct {
Class string `json:"_class"`
Handle string `json:"handle"`
GrampsID string `json:"gramps_id"`
Title string `json:"title"`
Author string `json:"author"`
Pubinfo string `json:"pubinfo"`
Abbrev string `json:"abbrev"`
NoteList []string `json:"note_list"`
MediaList []MediaRef `json:"media_list"`
AttributeList []SrcAttribute `json:"attribute_list"`
RepoRefList []RepoRef `json:"reporef_list"`
Change int64 `json:"change"`
TagList []string `json:"tag_list"`
Private bool `json:"private"`
}
Source represents a source of information in the Gramps database.
type SrcAttribute ¶
type SrcAttribute struct {
Class string `json:"_class"`
Private bool `json:"private"`
Type GrampsType `json:"type"`
Value string `json:"value"`
}
SrcAttribute represents a source attribute (different from Attribute).
type StyledText ¶
type StyledText struct {
Class string `json:"_class"`
String string `json:"string"`
Tags []StyledTextTag `json:"tags"`
}
StyledText represents formatted text with optional markup tags.
type StyledTextTag ¶
type StyledTextTag struct {
Class string `json:"_class"`
Name GrampsType `json:"name"`
Value string `json:"value"`
Ranges [][]int `json:"ranges"`
}
StyledTextTag represents a formatting tag within styled text.
func (*StyledTextTag) UnmarshalJSON ¶
func (s *StyledTextTag) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshalling for StyledTextTag. Gramps Python serializes the Value field as either a string or an integer (e.g., font size). This method accepts both.
type Surname ¶
type Surname struct {
Class string `json:"_class"`
Surname string `json:"surname"`
Prefix string `json:"prefix"`
Primary bool `json:"primary"`
Origintype GrampsType `json:"origintype"`
Connector string `json:"connector"`
}
Surname represents one surname component of a Name.