mirror of
				https://github.com/Theodor-Springmann-Stiftung/musenalm.git
				synced 2025-10-30 09:45:31 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			565 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			565 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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
 | |
| }
 | 
