mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-11-06 03:57:26 +01:00
updated import popup handling and api preview examples
This commit is contained in:
1 parent
65b830198b
commit
d56b8fcb90
13 files changed
+172
-99
No files matched your search
+16
-10
@@ -190,22 +190,28 @@ func (dao *Dao) ImportCollections(
|
||||
|
||||
mappedImported := make(map[string]*models.Collection, len(importedCollections))
|
||||
for _, imported := range importedCollections {
|
||||
// normalize ids
|
||||
// generate id if not set
|
||||
if !imported.HasId() {
|
||||
// generate id if not set
|
||||
imported.MarkAsNew()
|
||||
imported.RefreshId()
|
||||
} else if _, ok := mappedExisting[imported.GetId()]; !ok {
|
||||
imported.MarkAsNew()
|
||||
}
|
||||
|
||||
// extend existing schema
|
||||
if existing, ok := mappedExisting[imported.GetId()]; ok && !deleteMissing {
|
||||
schema, _ := existing.Schema.Clone()
|
||||
for _, f := range imported.Schema.Fields() {
|
||||
schema.AddField(f) // add or replace
|
||||
if existing, ok := mappedExisting[imported.GetId()]; ok {
|
||||
// preserve original created date
|
||||
if !existing.Created.IsZero() {
|
||||
imported.Created = existing.Created
|
||||
}
|
||||
imported.Schema = *schema
|
||||
|
||||
// extend existing schema
|
||||
if !deleteMissing {
|
||||
schema, _ := existing.Schema.Clone()
|
||||
for _, f := range imported.Schema.Fields() {
|
||||
schema.AddField(f) // add or replace
|
||||
}
|
||||
imported.Schema = *schema
|
||||
}
|
||||
} else {
|
||||
imported.MarkAsNew()
|
||||
}
|
||||
|
||||
mappedImported[imported.GetId()] = imported
|
||||
|
||||
Reference in new issue
Block a user