mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-30 01:35:32 +00:00
Personen DB Abfragen + Seiten
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user