Personen DB Abfragen + Seiten

This commit is contained in:
Simon Martens
2025-02-15 23:33:15 +01:00
parent 0aa8511ef0
commit e8edefa4b4
28 changed files with 949 additions and 65 deletions

View File

@@ -38,3 +38,29 @@ func PlaceForId(app core.App, id string) (*Place, error) {
}
return place, nil
}
func PlacesForEntry(app core.App, entry *Entry) (map[string]*Place, error) {
ids := []any{}
places := map[string]*Place{}
for _, r := range entry.Places() {
ids = append(ids, r)
}
if len(ids) == 0 {
return places, nil
}
p := []*Place{}
err := app.RecordQuery(PLACES_TABLE).
Where(dbx.HashExp{ID_FIELD: ids}).
All(&p)
if err != nil {
return nil, err
}
for _, place := range p {
places[place.Id] = place
}
return places, nil
}