mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
Places, Agents, Serials, Entries
This commit is contained in:
28
migrations/seed/common.go
Normal file
28
migrations/seed/common.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package seed
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func NormalizeString(s string) string {
|
||||
s = strings.TrimSpace(s)
|
||||
s = strings.ReplaceAll(s, "<div>", "")
|
||||
s = strings.ReplaceAll(s, "</div>", "")
|
||||
return s
|
||||
}
|
||||
|
||||
func batchSave(app core.App, records []*core.Record) error {
|
||||
app.RunInTransaction(func(txapp core.App) error {
|
||||
for _, record := range records {
|
||||
if err := txapp.Save(record); err != nil {
|
||||
app.Logger().Error("Error saving record.", "error", err, "record", record)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user