added custom goja field mapper to handle all caps identifiers and allowed errors unwrapping
This commit is contained in:
@@ -43,7 +43,7 @@ func (p *plugin) afterCollectionChange() func(*core.ModelEvent) error {
|
||||
template, templateErr = p.goDiffTemplate(new, old)
|
||||
}
|
||||
if templateErr != nil {
|
||||
return fmt.Errorf("failed to resolve template: %v", templateErr)
|
||||
return fmt.Errorf("failed to resolve template: %w", templateErr)
|
||||
}
|
||||
|
||||
var action string
|
||||
@@ -61,11 +61,11 @@ func (p *plugin) afterCollectionChange() func(*core.ModelEvent) error {
|
||||
|
||||
// ensure that the local migrations dir exist
|
||||
if err := os.MkdirAll(p.options.Dir, os.ModePerm); err != nil {
|
||||
return fmt.Errorf("failed to create migration dir: %v", err)
|
||||
return fmt.Errorf("failed to create migration dir: %w", err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(fileDest, []byte(template), 0644); err != nil {
|
||||
return fmt.Errorf("failed to save automigrate file: %v", err)
|
||||
return fmt.Errorf("failed to save automigrate file: %w", err)
|
||||
}
|
||||
|
||||
p.refreshCachedCollections()
|
||||
|
||||
@@ -35,7 +35,7 @@ func (p *plugin) jsBlankTemplate() (string, error) {
|
||||
func (p *plugin) jsSnapshotTemplate(collections []*models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collections, " ", " ")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `migrate((db) => {
|
||||
@@ -55,7 +55,7 @@ func (p *plugin) jsSnapshotTemplate(collections []*models.Collection) (string, e
|
||||
func (p *plugin) jsCreateTemplate(collection *models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collection, " ", " ")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `migrate((db) => {
|
||||
@@ -76,7 +76,7 @@ func (p *plugin) jsCreateTemplate(collection *models.Collection) (string, error)
|
||||
func (p *plugin) jsDeleteTemplate(collection *models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collection, " ", " ")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `migrate((db) => {
|
||||
@@ -329,7 +329,7 @@ func init() {
|
||||
func (p *plugin) goSnapshotTemplate(collections []*models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collections, "\t\t", "\t")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `package %s
|
||||
@@ -368,7 +368,7 @@ func init() {
|
||||
func (p *plugin) goCreateTemplate(collection *models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collection, "\t\t", "\t")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `package %s
|
||||
@@ -416,7 +416,7 @@ func init() {
|
||||
func (p *plugin) goDeleteTemplate(collection *models.Collection) (string, error) {
|
||||
jsonData, err := marhshalWithoutEscape(collection, "\t\t", "\t")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to serialize collections list: %v", err)
|
||||
return "", fmt.Errorf("failed to serialize collections list: %w", err)
|
||||
}
|
||||
|
||||
const template = `package %s
|
||||
|
||||
Reference in New Issue
Block a user